|
|
Subscribe / Log in / New account

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.)


to post comments

The Python "Need for Speed" Sprint

Posted May 28, 2006 22:40 UTC (Sun) by k8to (guest, #15413) [Link] (5 responses)

It's well known that perl is faster than python. Python stack frames are
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.

That all said, I find that the speed difference quite rarely matters.

Not PCRE

Posted May 29, 2006 2:44 UTC (Mon) by amk (subscriber, #19) [Link]

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.

Actually Perl is not always faster

Posted May 29, 2006 16:45 UTC (Mon) by scottt (guest, #5028) [Link] (2 responses)

A microbenchmark comparing Perl and Python: Computer Language Shootout

Actually Perl is not always faster

Posted May 29, 2006 23:10 UTC (Mon) by k8to (guest, #15413) [Link]

Actually beginning comments with "actually" is always slightly
bothersome.

Actually Perl is not always faster

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.

The Python "Need for Speed" Sprint

Posted May 29, 2006 20:42 UTC (Mon) by jafo (guest, #8892) [Link]

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.

Sean


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds