pythonjit._cythonhook

Provides a module finder class.

This is not a public facing module; Users of pythonjit should use pythonjit.enable to automatically compile imported modules, or pythonjit.cross_compile as a utility to compile modules without importing them in python (e.g. in order to distribute them).

The Import_Hook class inserts itself into sys.meta_path when instantiated. When import statements are used, Import_Hook has the opportunity to locate the file to be imported. It uses this opportunity to locate the .py source code file for the module (if available), and uses _compile.cross_compile it to a static library.

After that, it's job is done; It passes the responsibility to find and load modules to the next or default finder/loader. That finder/loader will find the compiled version of the imported module, which will be used instead of the source code version of the module.

Import_Hook

This object is automatically instantiated and inserted into sys.meta_path as the first entry when instantiated.

When a module is imported, this object is tasked with finding the module. This object will find the source code for the module, and cross compile it if necessary.

This object does not participate in the module loading part of the import process. After the source file is cross compiled, it is left to the default/other finders/loaders to load. The default loader will opt to load a compiled .so/.pyd over a .py file if it is available

Method resolution order:

(<class 'pythonjit._cythonhook.Import_Hook'>, <type 'object'>)