pythonjit

Automatically cross compiles .py files to .so (or .pyd on Windows) using Cython and import hooks.

How to use

Simply include the following at the earliest available point in your code:

    import pythonjit
    pythonjit.enable()

And any futher imports will automatically be cythonized, providing a modest performance benefit for no extra work and without compromising the pure python nature of source files.

For more performance benefits, use the decorators provided by cython to statically type variables and return types. These will not compromise the pure python nature of your source code - .py files that use these decorators can still be ran by the regular python interpreter.

The relevant decorators are:

Types are also part of the cython module:

For more information on cython types and decorators, see the cython docs

Bugs in your code and compilation time

Cython is more stringent than the python interpreter when it comes to catching errors in code. For example, it will complain about NameErrors that occur in unreachable code, which the python interpreter will not do. A larger/complex project may have issues to fix before Cython can compile it.

Cross compilation can take some time, especially for larger projects. A caching mechanism is used to compensate for this, so the first run will be slower than future runs.

Requirements:

Notes/Known issues/Complications: