loop in python
Peter Otten
__peter__ at web.de
Tue Aug 23 03:48:41 EDT 2005
km wrote:
> the first thing any newbie to python asks me is abt "raw speed in
> comparison with similar languages like perl" when i advocate python to
> perl.
In that case it is easy enough to follow the common industry practice and
tweak your test cases until your favourite product comes out faster.
$ time perl -e $'sub f() {for $i (0..10000000) {}} f();'
real 0m1.075s
user 0m1.073s
sys 0m0.000s
$ time python2.4 -c $'def f():\n for i in xrange(10000001): pass\nf()'
real 0m0.878s
user 0m0.871s
sys 0m0.005s
Working hypothesis: All benchmarks where Python comes out slower than Perl
are not done properly :-)
Peter
More information about the Python-list
mailing list