Perl code 37 times quickly than Python code??

Delaney, Timothy tdelaney at avaya.com
Tue Jan 15 19:58:26 EST 2002


> From: gaya at infomail.lacaixa.es [mailto:gaya at infomail.lacaixa.es]
> 
> And YES, this isn't a complete benchmark. But I think is a 
> representative
> example. I like programing in Python, but it seems that 
> Python people are
> always looking to speed things and do things in "strange 
> forms or manner". Why
> a example as simple as that runs many times quickly in perl 
> than python? it
> doesn't have explication. Two programs syntax are clear and simple....

A naive implementation of a benchmark will always show up one language to be
"better" than another. However, the first, naive version is often "fast
enough" for the purposes that you are using them for.

However, if you are looking for performance, you definitely want to push
tight loops out to pure C code. I think that Numeric has a ramp() function
(if not, it's some other common library).

Seriously, what you are doing is *not* a representative sample - it is not
the type of thing that Python is designed for. Nevertheless, people do use
Python for that type of thing because they use libraries to deal with
performance problems when they occur (e.g. Numeric, SciPy, Scientific
Python, PyGame).

Very rarely are Python people looking to speed things up except as an
academic exercise, although we all agree it would be nicer if things were
just magically faster.

Besides, I can't say I find the perl code particularly clear - despite it
being a fairly well-laid out piece of code, it still looks like line noise
...

Tim Delaney




More information about the Python-list mailing list