Menu
Microsoft’s Pyjion compiler for Python reaches 1.0

Microsoft’s Pyjion compiler for Python reaches 1.0

A Microsoft project to JIT-compile Python for speed, now under new developers, has reached a milestone.

Credit: Christina Morillo

Pyjion, a just-in-time (JIT) compilation system for Python that compiles to the .NET 6 runtime, is now available in a 1.0 version.

Pronounced “pigeon,” and developed by Python Software Foundation fellow and Microsoft fellow Anthony Shaw (as a fork from its original Microsoft codebase), Pyjion is not a standalone runtime like PyPy, but an installable library that runs under Python 3.10. 

Once installed, Pyjion can be used in a program simply by importing the Pyjion library and enabling it. Everything that runs after that statement is JIT-compiled.

Pyjion works by compiling Python virtual machine opcodes into assembly language by way of the .NET EE compiler. 

Benchmarks conducted by the project’s maintainers show that Pyjion is about two to three times faster than regular Python for real-world work. Some of the optimisations allow speedups of up to 10 times. Regular arithmetic, always a good candidate for being JIT-optimised, can be an order of magnitude faster.

Some Python features are not implemented yet in Pyjion, such as with blocks and async/await, but both are on the roadmap. Pyjion does include a middleware layer to allow WSGI applications to run under Pyjion. A long-running application like a web app is a good candidate for JIT acceleration.

It has historically been difficult to make Python faster for a whole slew of reasons. Most methods for speeding up Python still rely on the Python C API for compatibility, so performance can end up being limited by that. Cython, the project that compiles Python into C, achieves its best performance with code that has no reliance on the Python C API at all.

Although Pyjion still relies on the Python C API, its current and future-planned optimisations (e.g., optimising access to array types) show that its developers are thinking about how to deal with that.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags Microsoftpython

Featured

Slideshows

Show Comments