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

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Sat Aug 23 12:07:04 EDT 2003


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.

I can. :-)

I had to increase the loop counter by a factor of 10 because it
ran too fast on my machine (celeron 533 mhz), and added a print statement
of the accumulated sum (erg). These are my results:

[irmen at atlantis]$ gcc -O3 -march=pentium2 -mcpu=pentium2 -lm erf.c

[irmen at atlantis]$ time ./a.out
5190039.338694
4.11user 0.00system 0:04.11elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (103major+13minor)pagefaults 0swaps

[irmen at atlantis]$ time python2.3 erf.py
5190039.33869
2.91user 0.01system 0:02.92elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (544major+380minor)pagefaults 0swaps

This is with gcc 3.2.2 on Mandrake 9.1.

While Python + Psyco is not twice as fast as compiled & optimized C,
it's still faster by almost 30% on my system, which is still great!!

--Irmen





More information about the Python-list mailing list