Python 2 times slower than Perl

Gerhard Häring gerhard.nospam at bigfoot.de
Tue Jul 17 17:20:47 EDT 2001


On 17 Jul 2001 13:38:12 -0700, Xu, C.S. <xucs007 at yahoo.com> wrote:
>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

A JIT will surely eliminate the line "j = 2.5 * 2.5", as it is just a
no-operation. Perhaps Python doesn't, while Perl does?

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://highqualdev.com              public key at homepage
public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y: x+y, [chr(ord(x)^42) for x in list('zS^BED\nX_FOY\x0b')])



More information about the Python-list mailing list