Is there something equivalent to Cython for IronPython? That is, a way to compile simple functions using type annotations to increase performance? I know one of the benefits of IronPython is the ability to quickly write functions in something like C# or F# and then import them, but this can be somewhat of a burden for users who are only familiar with Python.
+1
A:
Hmm .. IronPython is already way faster than good ol' CPython :)
Having said that, you can create binaries from source with pyc (look in <IronPython 2.6 Install Dir>\Tools\Scripts\pyc.py
).
It looks like there are a number of output options, including making a dll. I presume it is possible to import
a dll like that from a regular .py
program (I've never tried this though).
I really don't know if this is going to increase performance beyond what you already get with IronPython though (it probably improves startup time).
Update:
I just did a bit of testing, and converting to exe gives me a really marginal 3-5% speed improvement, and doesn't help startup time. It seemed like a good idea :|
Seth
2010-01-12 22:26:42
I'm not talking about CPython, I'm talking about Cython. Cython is compiled C translated from Pythonesque code. This can lead to 500x increase in speed over CPython or Ironpython for numeric code.Second, it simply isn't true that IronPython is way faster than CPython: it is competitive, sometimes slower, sometimes faster. The Richards benchmark on that page is twice as slow for instance.
Tristan
2010-01-12 22:40:38
Sorry, I re-read my answer and can see how it would be a bit confusing. My point was that IronPython is already compiled into machine code dynamically; if you convert to EXE, you'll get a DLR binary image which will by automatically compiled into machine code. I can't imagine that you can get any faster than that (maybe writing a DLL in C# and calling into that would be faster, but then you'd be writing C#). Also - In my experience (with my programs), IronPython is faster than CPython if you exclude startup time (which is a lot to exclude).
Seth
2010-01-12 23:26:54