IronPython vs CPython: faster in 1.6 times?

Luis M. González luismgz at gmail.com
Tue Feb 5 18:19:43 EST 2008


On 5 feb, 14:31, dmitrey <dmitrey.kros... at scipy.org> wrote:
> Hi all,
> the urlhttp://torquedev.blogspot.com/2008/02/changes-in-air.html
> (blog of a game developers)
> says IronPython is faster than CPython in 1.6 times.
> Is it really true?
> If yes, what are IronPython drawbacks vs CPython?
> And is it possible to use IronPython in Linux?
>
> D.

I posted a little benchmark some time ago in ironpython's list that
showed a big performance gap between both implementations (being
cpython much faster than ironpython).
Jim Hugunin replied showing that making the script more abstract
(encapsulating code as much as possible into functions) the .NET
framework makes a better job at optimizing everything.

So I took Istvan script and made a little modification as follows:

import time

def foo(a):
    return a * a

def do():
    start = time.time()
    data = {}
    for i in xrange( 10**6 ):
        data[i] = foo(i)
    print 'Elapsed time:%5.2f s' % ( time.time() - start)

do() # pre-run to avoid initialization time
do()

import psyco
psyco.full()

print '\nNow with psyco...\n'

do()
do()

input()

The result is that it runs slighty faster in both, IP and CP, but
cpython is still faster (around 2x) than ironpython.
However, when using psyco simply blows everything out of the water...

These are my results.

Ironpython 2.0 Alpha 8:
    Elapsed time: 3.14 s
    Elapsed time: 3.36 s

cpyhon 2.5:
    Elapsed time: 1.55 s
    Elapsed time: 1.58 s

    Now with psyco...

    Elapsed time: 0.88 s
    Elapsed time: 0.80 s



More information about the Python-list mailing list