[Python-Dev] OT: A Day in the Life of p5p

Tim Peters tpeters@beopen.com
Wed, 28 Jun 2000 16:15:34 -0400


[Paul Prescod]
> ...
> When you optimize the snot out of things they tend to start looking
> ugly. Perl runs faster than Python. That's probably not a coincidence.

More, IMO it's not even true.  I can't make time for this now, but on
several occasions I've coded the same algorithm in idiomatic Perl and
Python, and Python was invariably faster (not talking orders of magnitude,
but 10-40%).

The catch is that I know something about both implementations, and avoided
the sweet spots in both.  Perl gets enormous bang out of its line-at-a-time
text file input "cheating", and its integrated regexps.  Avoid those, and
it's generally *slower* in my experience, which is perfectly consistent with
the relative messiness of its implementation (all those magic flags aren't
passive, they need runtime conditionals to use!  Perl can't even inline its
refcount manipulations because they're so complicated due to the flags).

Against that, line-at-a-time text file input in particular is something that
every newbie bumps into at once, and Perl does have a monster advantage
there (at least 2x faster, probably closer to 3 on most platforms).  Perl
doesn't really look like it was designed to "be fast" in general -- it looks
like it was designed to be supernaturally fast in specific situations.  Best
I've been able to tell, that's how it *acts*, too.

I'm keen to add comparable (but limited) internal warts to Python, but for
*general* speedup ideas we'll be much better off looking to, e.g., Dylan and
Squeak.

all-that-said-python-is-fast-enough-for-me-already!-ly y'rs  - tim