Perl vs. Python for text manipulation
rganesan at myrealbox.com
Sat Jan 24 17:12:58 CET 2004
>>>>> "Ville" == Ville Vainio <ville.spamstermeister.vainio at thisisspamprotectiontut.finland> writes:
>>>>> "Ganesan" == Ganesan R <rganesan at myrealbox.com> writes:
Ganesan> is nearly 6 times slower in python (8 time slower with
Ganesan> Python 2.2) using fileinput. Every appears to know that
Ganesan> fileinput is slower and avoid it when performance is a
Ganesan> concern; but even manually doing the equivalent is slower
Ganesan> in python. I've simply switched back to using perl for my
> A while back someone fixed his python script to use normal files
> instead of stdin, and the Python version proved to be even faster than
> the Perl version. Have you tried that?
Are you saying that iterating over normal files instead of stdin is faster?
I ran some tests just now and it doesn't seem to make any significant
difference. On the other hand, my current tests show that python is only 40%
slower than perl for IO instead of twice as slow as I mention
above. Something has changed for the better in python (or worse in perl!)
since I last ran the tests. I am running Debian testing versions of python
and perl. I'll run some more tests and share the test scripts and results
sometime next week.
More information about the Python-list