Speed Comparison Perl Python & C
Neil Hodgson
nhodgson at bigpond.net.au
Mon Mar 1 22:18:09 CET 2004
beliavsky at aol.com:
> As others pointed out, your programs mostly test the speed of I/O.
> Here is a simple comparison of the speed of integer arithmetic using
> Python and Fortran 95 (Compaq Visual Fortran 6.6, with full
> optimization).
It actually compares the speed of integers large enough to need 64 bits
of precision where Fortran can use a 64 bit integer and Python uses an
unbounded integer. The test can be sped up in two ways, first by using
floating point (which is fixed length in Python) and by using Psyco. On my
machine:
Original test: 245 seconds
Using floats: 148 seconds
Using psyco with integers: 69 seconds
Using psyco with floats: 18.4 seconds
Therfore gaining a speed up of 13 times. This leads to Fortran likely
remaining 22 times faster.
from psyco.classes import *
import psyco
def xx():
i = 1.0
j = 0.0
while i < 100000000.0:
j = j + i
i = i + 1
print int(j)
psyco.profile()
xx()
Neil
More information about the Python-list
mailing list