curry.backends.py.toolchain module
The build step of the Python backend: ICurry-JSON to a Python module, with its bytecode cache.
A generated file carries a format stamp (compiler.FORMAT_VERSION). Json2Py, the step that writes the file, refuses a cached file of another stamp, or of none; the plan then writes the file again from the JSON file. See is_stale.
- class curry.backends.py.toolchain.Json2Py(interp)[source]
Bases:
Json2TargetSource- NAME = 'json2py'
- SUFFIX = '.py'
- curry.backends.py.toolchain.bytecode_file(pyfile)[source]
The bytecode cache of a generated Python file, as importlib names it.
- curry.backends.py.toolchain.bytecode_is_current(pyfile)[source]
True when the bytecode cache of
pyfileexists and importlib would load it: its header names the size and the time stamp of the file as it is now, or, for a hash-based cache, the hash of its contents.
- curry.backends.py.toolchain.compile_bytecode(pyfile)[source]
Writes the bytecode cache of
pyfilebeside it, under__pycache__. The loader reads the cache instead of the source while the source keeps its size and time stamp. The cache is written whether or not the process runs with-B: it is a product of the toolchain, like the file itself, not a by-product of an import. A cache that cannot be written is logged and skipped; the file loads from source then.
- curry.backends.py.toolchain.ensure_bytecode(pyfile)[source]
Writes the bytecode cache of
pyfileunless a current one exists.