cpython
cpython copied to clipboard
Explain what a source module is
Documentation
In the 6th tutorial chapter about Modules, the term "source module" is used.
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.
It isn't really specified what a "source module" is exactly. I think the original python script/module and not the compiled pyc file(s) is meant but I also think this isn't really obvious here (although a hint is given by the phrase "To support a non-source (compiled only)" in the next sentence). My initial suggestion:
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, which refers to the non-compiled python script or 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.
I think this is reasonably obvious, we could maybe say "no source (.py) module".
A
Can we replace "source module" with "corresponding source code file" instead?
There is an instance of "source" that occurs in the paragraph just above the one you reference. I think it would be better to define it at the first occurrence of "source"? May I suggest something like the following?
Following @AA-Turner's suggestion (changes in ):
Python checks the modification date of the source (
.py) against the compiled (.pyc) version to see if it’s out of date and needs to be recompiled...
And following @arhadthedev's suggestion (changes in bold):
...Second, it does not check the cache if there is no corresponding source module...
Any thoughts?
@oda-gitso: sorry for the delayed answer, I think this is a good solution 👍🏼
I love concepts, definitions, rules, readability, and precision issues. How may I find easier? I beg your Pardon, if I am breaking some code of conduct here, but I had to begin writting instead just reading.