Pyjion is a drop-in JIT Compiler for Python 3.10. It can be pip installed into a CPython 3.10 installation on Linux, Mac OS X, or Windows.
Pyjion can make your Python code execute faster without any code changes.
Pyjion requires:
After following the installation steps, pyjion is a python module that you can import a Python 3.10 environment:
python -m pip install pyjion
After importing pyjion, enable the JIT using the enable function:
import pyjion; pyjion.enable()
Any Python code you define or import after enabling pyjion will be JIT compiled. You don’t need to execute functions in any special API, it’s completely transparent:
>>> def half(x):
... return x/2
>>> half(2)
1.0
You can also execute Pyjion against any script or module:
pyjion my_script.py
Or, for an existing Python module:
pyjion -m calendar
That’s it! For the full API, checkout the documentation.
Data is on a Linux X86_64 machine. Benchmark scripts are in the Pyjion source repo. Some benchmarks have a slow max/mean value because the time includes JIT-compiling large libraries like Pandas.
Pyjion is a JIT compiler. It compiles native CPython bytecode into machine code. Without Pyjion, CPython uses a master evaluation loop (called the frame evaluation loop) to iterate over opcodes The Pyjion compiler has 3 main stages: