Python 2 times slower than Perl
Xu, C.S.
xucs007 at yahoo.com
Wed Jul 18 03:05:24 EDT 2001
Thanks for all comments. Now I revised my stupid testing
python script to adopt both a func (save original 38 seconds
to 28 seconds) and a for loop (save original 38 seconds to
21 seconds), I got 16.0 seconds, which is pretty comparable
to perl's 15.4 seconds.
The revised stupid testing py is:
#!/usr/bin/env python
def f():
for i in xrange(2.5, 1e7, 1.):
j = 2.5 * 2.5
print i, j
f()
Interesting is for perl: On the same PII 450 MHz, "for" loop
in stead of "while" loop increase about 10% speed, but on another
PIII 1GHz, "for" slowes down speed by 30% (from 8 seconds of
"while" to 10.6 seconds of "for"). Only computers themselves
can understand, :-(
More information about the Python-list
mailing list