cpython icon indicating copy to clipboard operation
cpython copied to clipboard

Explain what a source module is

Open realjanpaulus opened this issue 3 years ago • 4 comments
trafficstars

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.

realjanpaulus avatar May 31 '22 13:05 realjanpaulus

I think this is reasonably obvious, we could maybe say "no source (.py) module".

A

AA-Turner avatar May 31 '22 22:05 AA-Turner

Can we replace "source module" with "corresponding source code file" instead?

arhadthedev avatar Jun 01 '22 05:06 arhadthedev

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?

ghost avatar Jun 01 '22 09:06 ghost

@oda-gitso: sorry for the delayed answer, I think this is a good solution 👍🏼

realjanpaulus avatar Aug 16 '22 07:08 realjanpaulus

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.

GiovanniHD201E avatar Sep 20 '22 03:09 GiovanniHD201E