Perl is faster than Python

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.

Interesting:

A related question is: why is Perl so fast?
Quite a few years ago I wrote a little Runge-Kutta solver in Perl for some simulation work. It seemed like a good idea at the time. The equations of motion had to be integrated over a very long time, and it could take hours for a single run (still much faster than the Monte Carlo it was being used to do a sanity-check on). I re-wrote everything in C++, and picked up less than a factor of two in speed.

So it isn’t that “Python is interpreted” that is the problem, because “Perl is interpreted” in exactly the same way. It really does seem to come down to the Python object model. Perl’s scalar types have vastly less overhead, so much so that you can actually do reasonably efficient numerical computation in it.

I abandoned Perl for Python shortly thereafter because once I got over the “oh my god it’s full of whitespace” thing Python was just more fun to code in, but the speed that Perl provided is something I’ve definitely missed, and it was a real awakening to the notion that interpreted languages don’t have to be slow. The striking thing was that unlike Java (say) where it can be fast but you generally have to think about it, I was getting fast Perl without even really trying.

Post external references

  1. 1
    https://news.ycombinator.com/item?id=8625280
Source