Speed of Python vs. Perl

Tim Peters tim.one at home.com
Mon Jan 8 01:29:15 EST 2001


[David Allen]
> From what I've seen and heard, if you must have an answer, it's
> probably that perl may have a slight edge.

It depends very much on what you're doing (and how you're doing it <wink>).

> But realistically, the question is loaded, since python and
> perl don't often do things in the same way.

That's for sure.  Over the past week, several wrestled (behind the scenes)
with the relatively poor speed of f.readline() in Python (as compared to
"<f>" in scalar context in Perl).  Turns out that the single biggest
contributor to the difference is that Python reads in a threadsafe way while
Perl doesn't:  Python spends over half its time in system stream
locking/unlocking routines called by threadsafe system getc() (and friends).
Now that we know that, we were able to make large improvements (which will
be in Python 2.1) -- but it will never be as fast as thread-unsafe input.

it's-more-fun-to-use-python-than-to-implement-it<wink>-ly y'rs  - tim





More information about the Python-list mailing list