Comparing perl and python

Aahz Maruch aahz at netcom.com
Wed Feb 23 01:07:47 EST 2000


In article <his6bs08biqdkasl8cis6t9bk6pfd5onc0 at 4ax.com>,
Tim Roberts  <timr at probo.com> wrote:
>
>It's clear that there is a substantial library of modules for python,
>approaching that of perl.  However, I am disturbed by what seems to be a
>dramatic performance difference.  I've tried writing some simple test cases
>in both languages, and I'm finding python to be 2x, 3x, and in one case 12x
>slower than the equivalent program in perl.  (The 12x case was a simple
>"grep the files in stdin", using the "re" and "multifile" modules in
>python.)

In raw speed, Perl tends to run about twice as fast for the most
"obvious" way to do things.  This advantage spreads to 5x or 10x when
you talk about the "obvious" way to do certain kinds of I/O.

The advantage diminishes rapidly when you compare the code of expert
programmers, and it mostly vanishes when you start looking at real,
complex programs.  Main reason for that is that Python code is so much
easier to write, you spend more time looking at the algorithms -- that's
where you get your order of magnitude increases in performance.

Remember that Perl is optimized to be a "super AWK".  And IMO, that's
about all it's good for.
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Love does not conquer all.  Humans are extremely flexible, usually more
flexible than we're willing to admit.  But some flexibility comes at a
cost, and sometimes that cost is more than we can bear.



More information about the Python-list mailing list