Fw: Re: Python is darn fast (was: How fast is Python)

Pedro Werneck pedro.werneck at bol.com.br
Sat Aug 23 21:14:14 EDT 2003


On 23 Aug 2003 08:37:44 -0700
mis6 at pitt.edu (Michele Simionato) wrote:

> I posted this few weeks ago (remember the C Sharp thread?) but it went
> unnoticed on the large mass of posts, so let me retry. Here I get
> Python+ Psyco twice as fast as optimized C, so I would like to now if
> something is wrong on my old laptop and if anybody can reproduce my
> results. Here are I my numbers for calling the error function a
> million times(Python 2.3, Psyco 1.0, Red Hat Linux 7.3, Pentium II 366
> MHz):


My timings on a K6-2 500 MHZ (450 overcloked to 500), Slackware 8.1. I
increased the loop counter by 10:


gcc-2.95.3:

$ gcc -O3 -lm erf.c && time ./a.out  

real    0m6.807s
user    0m6.650s
sys     0m0.010s


Is not much different from gcc-3.3.1:

$ gcc-3 -O3 -lm erf.c && time ./a.out

real    0m6.677s
user    0m6.460s
sys     0m0.010s


And even with gcc-3.3.1 and cpu flags:

$ gcc-3 -O3 -march=k6-2 -lm erf.c && time ./a.out

real    0m6.411s
user    0m6.400s
sys     0m0.000s

But with the suggested -ffast-math flag:

$ gcc-3 -O3 -march=k6-2 -mcpu=k6-2 -ffast-math -lm erf.c && time ./a.out

real    0m2.598s
user    0m2.590s
sys     0m0.010s

And finally, with Python 2.3 + Psyco 1.1.1:

$ time python2.3 erf.py

real    0m4.900s
user    0m4.470s
sys     0m0.080s


Very surprising :)


Pedro Werneck










More information about the Python-list mailing list