The Python "Need for Speed" Sprint
The Python "Need for Speed" Sprint
Posted May 28, 2006 21:32 UTC (Sun) by jengelh (guest, #33263)Parent article: The Python "Need for Speed" Sprint
We started the week with the Python 2.5 alpha 2 release candidate being around 10% slower than 2.4.3, the previous stable release. Largely, this slowdown is due to newly added features, particularly a change in the object type of exceptions which is showing a 60% slowdown.
That's quite heavy. Python already runs slower than Perl for a given program ("converting" a binary file to a C source file),
$ time png2c.pl -C images.cpp -H images.hpp sside.png ssplash.png vsplash.png; time png2c.py -C images.cpp -H images.hpp sside.png ssplash.png vsplash.png;
real 0m0.499s
user 0m0.460s
sys 0m0.040s
real 0m1.679s
user 0m1.650s
sys 0m0.030s (both are hot runs, i.e. all used files have been cached by the kernel before)
Either I suck at writing Python, or regexes are in fact slower. This is Python 2.4.2. (Post a comment if you want the progs.)
Posted May 28, 2006 22:40 UTC (Sun)
by k8to (guest, #15413)
[Link] (5 responses)
That all said, I find that the speed difference quite rarely matters.
Posted May 29, 2006 2:44 UTC (Mon)
by amk (subscriber, #19)
[Link]
Posted May 29, 2006 16:45 UTC (Mon)
by scottt (guest, #5028)
[Link] (2 responses)
Posted May 29, 2006 23:10 UTC (Mon)
by k8to (guest, #15413)
[Link]
Posted Jul 15, 2006 21:02 UTC (Sat)
by Barry (guest, #39099)
[Link]
There's some data based on the Computer Language Shootout at the bottom of this page.
On Debian : AMD Sempron, Python performed faster than Perl in 9 out of 15 benchmarks.
On Gentoo : Intel® Pentium® 4, Python performed faster than Perl in 13 out of 16 benchmarks.
Posted May 29, 2006 20:42 UTC (Mon)
by jafo (guest, #8892)
[Link]
Sean
It's well known that perl is faster than python. Python stack frames are The Python "Need for Speed" Sprint
heavier; python variable access is heavier. It _might_ be that the
regexes are slower too, and it wouldn't surprise me, but I bet they use
PCRE, so I'd chalk it up to the overall language first.
PCRE was used in Python 1.5.2, but it doesn't support 16-bit Unicode characters (only UTF-8
encoded strings), so Python now uses its own regex engine.
Not PCRE
A microbenchmark comparing Perl and Python:
Computer Language Shootout
Actually Perl is not always faster
Actually beginning comments with "actually" is always slightly Actually Perl is not always faster
bothersome.
Actually Perl is not always faster
One of the areas that was worked on was speeding up function calls, including changes related specifically to the frames. There isn't much that can be done about reducing the frame size, but I think a small reduction was done there. However, Richard Jones spent the first day of the sprint updating a patch which used zombie frames so that repeated calls to a function would use a cached frame that was already mostly initialized.The Python "Need for Speed" Sprint
