Perl vs. Python for text manipulation

John J. Lee jjl at
Sat Jan 24 16:25:24 CET 2004

Ganesan R <rganesan at> 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.


More information about the Python-list mailing list