I like that you've made it clear in the docstring that it can't handle Lagrangians with higher derivatives. This isn't handling the special case where you can integrate directly is it? I know that Maple's original Euler-Lagrange function (in the calculus of variations package) was really slow because of that. I wrote my own code to handle the cases I was interested in and got over two orders of magnitude increase in speed (~10s to <0.1s), but if I removed their handling of the special case, their code took less than 1s.

I really should look at the code for this as it's something I'm very familiar with, but I'm busy with my post-doc work and marking reports.