Python speed and `pcre'

Hrvoje Niksic hniksic at srce.hr
Tue Aug 31 20:12:38 EDT 1999


François Pinard <pinard at iro.umontreal.ca> writes:

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

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.)  I don't think the speed different is related to compiling the 
regexps, although it is certainly possible.  Python is significantly
slower at executing regexps, as well as in simple tasks such as
reading from a file.

In most cases this is not a problem, but sometimes, like with the said 
large files, 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.




More information about the Python-list mailing list