Issue 13915: Update tutorial/modules for PEP 3147 (original) (raw)

http://docs.python.org/py3k/tutorial/modules.html#compiled-python-files needs to be updated for 3.2+ to reflect http://python.org/dev/peps/pep-3147/

The first sentence is still technically correct, but finding x.pyc in the same directory as x.py is now an anomaly, so that sentence, revised, should be near the bottom. Otherwise, the text should say that the default is to put x..pyc in pycache, where is, for instance, 'cpython-32'. Note that this allows other implementations and other versions of cpython to use the same .py file.

I do not know if there is anywhere else that this info is or should be. Using Python?.

I apologize for not submitting this in patch format, but I don't have a development system available.

I suggest replacing the entire 6.1.3 section with:

To speed up loading modules, Python caches the compiled version of each module in the pycache directory under the name module.cpython-xy.pyc, where xy is the Python version number. For example, in release 3.2 the compiled version of spam.py would be cached as pycache/spam.cpython-32.pyc. This naming convention allows compiled modules from different releases and different versions of Python to coexist.

Python checks the revision date of the source against the compiled version to see if it’s out of date and needs to be recompiled. This is a completely automatic process. Also, the compiled modules are platform-independent, so the same library can be shared among systems with different architectures.

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.

Some tips for experts: