PyDocs

Nav

Importing Modules

cache_from_source

importlib.util

function · Added in 3.4 (source)
  • cache_from_source(path, *, optimization=None)
Given the path to a .py file, return the path to its .pyc file.

The .py file does not need to exist; this simply returns the path to the
.pyc file calculated as if the .py file were imported.

The 'optimization' parameter controls the presumed optimization level of
the bytecode file. If 'optimization' is not None, the string representation
of the argument is taken and verified to be alphanumeric (else ValueError
is raised).

If sys.implementation.cache_tag is None then NotImplementedError is raised.
Changed in 3.5, 3.6, 3.15
  • 3.5: The optimization parameter was added and the debug_override parameter was deprecated.
  • 3.6: Accepts a path-like object.
  • 3.15: The debug_override parameter was removed.
0 Examples
No examples for importlib.util/cache_from_source.
See Also
No see-alsos for importlib.util/cache_from_source
0 Notes
No notes for cache_from_source