Perl vs. Python for text manipulation
Ganesan R
rganesan at myrealbox.com
Sat Jan 24 11:16:55 EST 2004
>>>>> "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.
Ganesan
--
Ganesan R
More information about the Python-list
mailing list