Answer the question
In order to leave comments, you need to log in
How does module compilation work in python?
I'm reading the documentation of modules in Python, I can't understand the penultimate paragraph in the compilation block: https://docs.python.org/3/tutorial/modules.html#co...
Python does not check the cache in two circumstances. First, it always recompiles
and does not store the result for the module that's loaded directly from the command line
Second, it does not check the cache if there is no source module. To support a non-source (compiled only) distribution, the compiled module must be in the source directory and there must not be a source module.
Answer the question
In order to leave comments, you need to log in
First, it always recompiles and does not store the result for the module that's loaded directly from the command line.
python test.py
, then it doesn't matter if there is a test.pyc. And if test.py is imported from another script or interactive interpreter session, the compiled version from the cache will be loaded.Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question