[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

IronPython vs CPython: faster in 1.6 times?

dmitrey

2/5/2008 5:31:00 PM

Hi all,
the url http://torquedev.blogspot.com/2008/02/changes-i...
(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.
25 Answers

Jeff

2/5/2008 6:16:00 PM

0

IronPython runs on top of .NET. I would be suspect of any claims that
it is faster than cPython, just as I would of claims that Stackless or
Jython are faster.

Steve Holden

2/5/2008 6:52:00 PM

0

Jeff wrote:
> IronPython runs on top of .NET. I would be suspect of any claims that
> it is faster than cPython, just as I would of claims that Stackless or
> Jython are faster.

Well don't be. There are benchmarks that clearly show IronPython as
faster for selected tests. Other tests show CPython running more quickly.

As always, a benchmark is only really valuable on a typical workload for
the intended application.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.hold...

Mike C. Fletcher

2/5/2008 7:23:00 PM

0

dmitrey wrote:
> Hi all,
> the url http://torquedev.blogspot.com/2008/02/changes-i...
> (blog of a game developers)
> says IronPython is faster than CPython in 1.6 times.
> Is it really true?
>
On certain platforms, I believe so, for certain types of operations.
Not sure if Mono also provides a speedup. Most of the speedup is due to
large amounts of (paid) effort being spent creating a high-speed ILM
optimizer. Because IronPython can make use of the work that MS has been
poring into Dynamic language compilation, it can get quite a few
speedups that CPython just doesn't get because they don't have the
people to do the work. Optimising code automatically is a reasonably
complex process that tends to introduce lots of potential errors. The
CPython devs are not AFAIK working on performance much these days, so
likely CPython won't improve any time soon, i.e. 3.0 will likely not be
any faster than 2.5 from anything I've heard.

PyPy is attempting to address this issue via a separate interpreter, but
it's currently just playing catch-up on performance most of the time.
It does have a JIT, and might one day be fast enough to be a usable
replacement for CPython, but it will require a lot of developer-years to
get it there, most likely.

It would be really nice if PyPy could get Python 2.5 running say 5x
faster and then run with that. With that Python would open out into
entire new areas of applicability, becoming reasonable as an embedded
language, or a systems language. Only 2x slower than C would make
Python pretty close to a perfect language...
(far more attractive than a slightly tweaked syntax IMO). That's
probably 5-10 developer years out, though, not counting any distractions
from trying to support Python 3.x.
> If yes, what are IronPython drawbacks vs CPython?
>
Mostly library access from what I understand. Numpy and SciPy, for
instance, are not AFAIK ported to IronPython. Those are the people who
*really* need speed, and without those APIs having "Python" available
faster doesn't really mean much. IronPython has access to the Win32
API, so if you want to use Win32 APIs, rather than the CPython ones,
you're golden, but Numpy/SciPy's interface is *really* elegant for
working with large arrays of data.

If you're trying to write tight numeric loops for gigabyte arrays in raw
Python, 1.6 times performance isn't really usable... even 5x is just
barely usable. Numpy lets you use the optimized (C) libraries for the
heavy lifting and Python friendliness where you interact with humans.
If Python were 10x faster you *might* completely rewrite your Numpy in
Python code, but I'd expect that naive Python code would still be beat
handily by BLAS or what have you under the covers in Numpy.

If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.

are the two lines that tend to preclude CPython ever becoming *really*
fast. Optimizing code is almost always complex and hard to explain.
You need lots and lots of thought to make a compiler smart enough to
wring performance out of naive code, and you need a lot of thought to
reason about what the compiler is going to do under the covers with your
code. IronPython (and Jython, and Parrot) can use the underlying
system's complexity without introducing it into their own project. PyPy
is trying to create the complexity itself (with the advantage of a
smaller problem domain than optimising *every* language).
> And is it possible to use IronPython in Linux?
>
Yes, running on Mono, though again, I don't believe Mono has had the
optimisation effort put in to make it competitive with MS's platforms.

Just my view from out in the boonies,
Mike

Bearophile

2/5/2008 7:40:00 PM

0

Mike C. Fletcher:
> Not sure if Mono also provides a speedup.

There is a set of good benchmarks here, the answer is negative:
http://shootout.alioth.debian.org/sandbox/benchmark.php?test=all&...

Bye,
bearophile

Stefan Behnel

2/5/2008 7:48:00 PM

0

bearophileHUGS@lycos.com schrieb:
> Mike C. Fletcher:
>> Not sure if Mono also provides a speedup.
>
> There is a set of good benchmarks here, the answer is negative:
> http://shootout.alioth.debian.org/sandbox/benchmark.php?test=all&...

This doesn't look like Mono to me:

IronPython 1.1 (1.1) on .NET 2.0.50727.42

Stefan

Istvan Albert

2/5/2008 8:01:00 PM

0

On Feb 5, 12:31 pm, dmitrey <dmitrey.kros...@scipy.org> wrote:
> Hi all,
> the urlhttp://torquedev.blogspot.com/2008/02/changes-i...
> (blog of a game developers)
> says IronPython is faster than CPython in 1.6 times.
> Is it really true?

This is a second time around that IronPython piqued my interest
sufficiently to create a toy program to benchmark it and I must say
the results are not encouraging:

$ python bench.py
Elapsed time: 1.10 s

$ ipy bench.py
Elapsed time:65.01 s

and here is the benchmark program:

import time
start = time.time()

def foo(a):
return a * a

data = {}
for i in xrange( 10**6 ):
data[i] = foo(i)

print 'Elapsed time:%5.2f s' % ( time.time() - start)

Christian Heimes

2/5/2008 9:51:00 PM

0

dmitrey wrote:
> Hi all,
> the url http://torquedev.blogspot.com/2008/02/changes-i...
> (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?

IronPython implements only a limited subset of Python. [1] All extension
that depend on a C code don't work under IronPython.

Christian

[1]
http://www.codeplex.com/IronPython/Wiki/View.aspx?title=Differences&referring...

Arnaud Delobelle

2/5/2008 9:56:00 PM

0

On Feb 5, 8:01 pm, Istvan Albert <istvan.alb...@gmail.com> wrote:
> On Feb 5, 12:31 pm, dmitrey <dmitrey.kros...@scipy.org> wrote:
>
> > Hi all,
> > the urlhttp://torquedev.blogspot.com/2008/02/changes-i...
> > (blog of a game developers)
> > says IronPython is faster than CPython in 1.6 times.
> > Is it really true?
>
> This is a second time around that IronPython piqued my interest
> sufficiently to create a toy program to benchmark it and I must say
> the results are not encouraging:
>
> $ python bench.py
> Elapsed time: 1.10 s
>
> $ ipy bench.py
> Elapsed time:65.01 s
>
> and here is the benchmark program:
>
> import time
> start = time.time()
>
> def foo(a):
>     return a * a
>
> data = {}
> for i in xrange( 10**6 ):
>     data[i] = foo(i)
>
> print 'Elapsed time:%5.2f s' % ( time.time() - start)

Could it be because .NET doesn't have arbitrary length integer types
and your little benchmark will create lots of integers > 2**32 ?
What is the result if you replace foo(a) with

def foo(a): return sqrt(a)

--
Arnaud

Istvan Albert

2/5/2008 10:33:00 PM

0

On Feb 5, 4:56 pm, Arnaud Delobelle <arno...@googlemail.com> wrote:

> Could it be because .NET doesn't have arbitrary length integer types
> and your little benchmark will create lots of integers > 2**32 ?
> What is the result if you replace foo(a) with

> def foo(a): return sqrt(a)

Good observation, in the case above the run times are about the same.

i.


Mensanator

2/5/2008 10:36:00 PM

0

On Feb 5, 3:56 pm, Arnaud Delobelle <arno...@googlemail.com> wrote:
> On Feb 5, 8:01 pm, Istvan Albert <istvan.alb...@gmail.com> wrote:
>
>
>
>
>
> > On Feb 5, 12:31 pm, dmitrey <dmitrey.kros...@scipy.org> wrote:
>
> > > Hi all,
> > > the urlhttp://torquedev.blogspot.com/2008/02/changes-i...
> > > (blog of a game developers)
> > > says IronPython is faster than CPython in 1.6 times.
> > > Is it really true?
>
> > This is a second time around that IronPython piqued my interest
> > sufficiently to create a toy program to benchmark it and I must say
> > the results are not encouraging:
>
> > $ python bench.py
> > Elapsed time: 1.10 s
>
> > $ ipy bench.py
> > Elapsed time:65.01 s
>
> > and here is the benchmark program:
>
> > import time
> > start = time.time()
>
> > def foo(a):
> >     return a * a
>
> > data = {}
> > for i in xrange( 10**6 ):
> >     data[i] = foo(i)
>
> > print 'Elapsed time:%5.2f s' % ( time.time() - start)
>
> Could it be because .NET doesn't have arbitrary length integer types

A good reason to not use it.

> and your little benchmark will  create lots of integers > 2**32 ?
> What is the result if you replace foo(a) with
>
> def foo(a): return sqrt(a)
>
> --
> Arnaud- Hide quoted text -
>
> - Show quoted text -