Python speed and `pcre'

François Pinard pinard at iro.umontreal.ca
Thu Sep 2 08:53:48 EDT 1999


Hrvoje Niksic <hniksic at srce.hr> écrit:

> > After having translated some code (not big, but not small) from Perl
> > to Python, I discover it runs ten times slower.

Hello, Hrvoje.  You are interested in Python, too?  Good news to me! :-)

> This is my usual result when comparing just about any code where speed
> actually matters (for me it's usually processing of large textual files.)

Are you serious?  Scheme is based, like Python, on dynamic typing, and from
my experience, is acceptably fast processing large files.  And a compiler
is available to get more speed, which produces code that might start to
compete with C when, the proper pragmas are added.  (I'm using Gambit, which
compiles pre-optimised C, but then, C has not much optimisation to add.)

I do not have all the time I would like to have to study these issues right
now, and I quite guess that Guido knows them inside out.  Since I'm still
naive at Python, I'm entitled to some surprise for a while! :-) Allow me
for some feet stamping...

> [...] sometimes [...] it is really disappointing to think about rewriting
> a very nice piece of Python code to Perl for efficiency reasons.
> People who embrace Python as a "better Perl" should really beware the
> speed difference.

Of even worse, using a cluttered Python style as an attempt to recover
a small part of the lost speed.  I'm ready to reasonably trade speed for
clarity, but I would not like ending loosing both!  (I'm exaggerating a bit
while I say so, because overall, Python appears clearer to me.  For heavy
Perl5 with recursive structures and such, equivalent Python is even shorter).

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list