Perl vs. Python for text manipulation

Serge Orlov sombDELETE at pobox.ru
Sat Jan 24 11:30:39 EST 2004


"Ganesan R" <rganesan at myrealbox.com> wrote in message news:ou4qulnwy0.fsf at andlx-anamika.cisco.com...
> >>>>> "John" == John J Lee <jjl at pobox.com> writes:
>
> > Ganesan R <rganesan at myrealbox.com> writes:
> >> > Is that all that people mean, though, when they talk about Perl's
> >> > superiority for text mangling?  Is there more to it?  --
> > [...]
> >> The perl "built-in" idioms for text processing is not only a syntactic
> >> convenience, there are real performance advantages. For example a simple
> >> perl loop like
> >>
> >> while (<>) { }
> >>
> >> is nearly 6 times slower in python (8 time slower with Python 2.2) using
> > [...]
>
> > Did you try 'for line in file:'?  ISTR Tim Peters optimized that (or
> > was that fileinput?), precisely because of every hacker and their dog
> > running this as a benchmark.
>
> fileinput is not optimized yet, at least I don't remember any mails about
> fileinput in python-devel since python 2.3 was released.  I know that it is
> slow. for line in file: does seem to be optimized though. The last time I
> ran the tests python was definitely twice as slow (which was before python
> 2.3 was officially released); now it appears to be only about 40% slower. I
> need to revisit these crude benchmarks.

Since this problem is not IO bound but rather python internals bound,
it makes sense to try psyco.





More information about the Python-list mailing list