Why is IronPython faster than the Official Python Interpreter

10,768

Solution 1

Python code doesn't get compiled to C, Python itself is written in C and interprets Python bytecode. CIL gets compiled to machine code, which is why you see better performance when using IronPython.

Solution 2

You're right, C is a lot faster. That's why in those results CPython is twice as fast when it comes to dictionaries, which are almost pure C. On the other hand, Python code is not compiled, it's interpreted. Function calls in CPython are terribly slow. But on the other hand:

TryRaiseExcept:  +4478.9%

Now, there's where IronPython get is horribly wrong.

And then, there is this PyPy project, with one of the objectives being Just-In-Time compiler. There is even subset of Python, called RPython (Reduced Python) which can be statically compiled. Which of course is a lot faster.

Solution 3

I'm not sure exactly how you're drawing the conclusion that IronPython is faster than CPython. The link that you post seems to indicate that they're good at different things (like exceptions as has been pointed out).

Solution 4

Wandering off your question "Why?", to "Oh, really?" The "good at different things" (Jason Baker) is right on. For example, cpython beats IronPython hands down start up time.

c:\Python26\python.exe Hello.py
c:\IronPython\ipy.exe Hello.py

Cpython executes a basic hello world nearly instantly(<100ms), where IronPython has an startup overhead of 4 or 5 seconds. This annoys me, but not enough to keep me from using IronPython.

Solution 5

Could it be explained by this notation on the page you linked to:

Due to site caching in the Dynamic Language Runtime, IronPython performs better with more PyStone passes than the default value

Share:
10,768
Tristan Havelick
Author by

Tristan Havelick

I'm a full-stack web software engineer My professional work currently centers around Python/React/PHP but in the past I've done a lot of Ruby and ASP/ASP.Net/C# stuff. I know a little of a ton of languages, and I'm currently honing managerial skills as well as getting better with front end tech.

Updated on June 16, 2022

Comments