Python 2 times slower than Perl
johann at physics.berkeley.edu
Wed Jul 18 18:26:27 CEST 2001
Peter Hansen writes:
> In practice, we've found Python to be somewhere between
> 30 and 100 times slower than C, clearly depending on the
> algorithm and without really much effort to optimize.
> (That is, our Python code could probably withstand
> some significant optimization, if we cared to.)
I've been playing with ocaml, so I thought I'd try the results on my
computer, a Mac PowerBook G3/400. Things don't look so good for the
G3/400 processor though, at least on OS X.
cc -O2 0.28
ocamlopt 1.26 (compiled)
ocaml 9.42 (interpreted)
Hm. I'm beginning to wonder if I compiled python with -O2 or not.
Plus, I'm becoming more and more fond of ocaml.
The python function I used was the basic
def test ():
i = 2.5
j = 2.5
while i < 1e7:
j = 2.5 * 2.5
i = i + 1.0
print "%f %f\n" % (i, j)
if __name__ == '__main__':
More information about the Python-list