Speed problems with Python vs. Perl

Fredrik Lundh fredrik at pythonware.com
Wed Mar 28 11:46:14 EST 2001


Christopher A. Craig wrote:
> with Python 2.0 and Perl 5.6.0 on a Celeron 300A using a 242000 line
> input file and I got the following results:
>
> python: 61.10s user 0.42s system 87% cpu 1:10.37 total
> perl:   11.31s user 0.10s system 76% cpu 14.960 total
>
> admittedly Python is being hurt by the slower 2.0 line I/O, but I
> would guess that regular expressions are still hurting performance.

s/regular expressions/re.split/g

note that re.split is written in Python, while I'm pretty
sure Perl's split is written in C.

to get a better idea of how fast the regular expression
engine itself is, run your benchmark with "findall" instead
of "split".

Cheers /F





More information about the Python-list mailing list