Python 2 times slower than Perl

Xu, C.S. xucs007 at yahoo.com
Tue Jul 17 16:38:12 EDT 2001


I just compared the speed of Python, Perl, Java, C
to do simple numerical calculations. Python is the
slowest: took 150 times of time than C, Perl about
60 times, Java is 4.5 times. 

The source code of Python is: (Other source are
similar, all use while loop):

#!/usr/bin/env python
i = 2.5;
while i < 1e7:
        j = 2.5 * 2.5
        i += 1
print i, j

The `time` results on my PII 450M is:
	python script:	37.93u 0.03s 0:38.03 99.8%
	perl script:	15.36u 0.03s 0:15.42 99.8%
	java compiled:	1.07u 0.10s 0:01.20 97.5%
	C compiled:	0.24u 0.01s 0:00.25 100.0%

Can anybody explain why Python is always about 1 time
slower than Perl?

Regards,



More information about the Python-list mailing list