Comparing perl and python

Tim Roberts timr at probo.com
Wed Feb 23 00:43:00 EST 2000


I've been reading this newsgroup for a couple of weeks, and I'm a bit
afraid my subject line might label me as a troll, but as a python newbie,
it is one which interests me.

I've done a couple of projects in python as a way of learning it, including
some text processing and a couple of CGI scripts.  Thus far, I find I
prefer the python syntax to perl; I think it makes for
easier-to-read-programs.  Further, although it might be more related to the
way I learned perl, I find that perl tends to encourage monolithic
programs, whereas python seems to lend itself more easily to a more
modularized structure.  These are both Good Things.

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.)

Now, it's possible this is just because python is version 1.6 and perl is
version 5; maybe python hasn't had the attention to optimization that perl
has, but I'd like to know if my experiences are unique.  Have others done
such comparisons?
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list