diff options
author | slateny <46876382+slateny@users.noreply.github.com> | 2022-04-26 19:12:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 19:12:02 (GMT) |
commit | b87f7f2c213225cbe5c4bd8f8a83883e0824c7d0 (patch) | |
tree | d17691a6ca3e2b5fb136146eb9826ed9e93820ed /Doc/reference/import.rst | |
parent | f703c96cf08a0d65e718e7acfb043cbc49812a22 (diff) | |
download | cpython-b87f7f2c213225cbe5c4bd8f8a83883e0824c7d0.zip cpython-b87f7f2c213225cbe5c4bd8f8a83883e0824c7d0.tar.gz cpython-b87f7f2c213225cbe5c4bd8f8a83883e0824c7d0.tar.bz2 |
bpo-21761: Clarify __file__/__cached__ in import reference (GH-31565)
Automerge-Triggered-By: GH:brettcannon
Diffstat (limited to 'Doc/reference/import.rst')
-rw-r--r-- | Doc/reference/import.rst | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index 988d41c..3a41403 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -610,15 +610,16 @@ the module. import system may opt to leave it unset if it has no semantic meaning (e.g. a module loaded from a database). - If ``__file__`` is set, it may also be appropriate to set the - ``__cached__`` attribute which is the path to any compiled version of + If ``__file__`` is set then the ``__cached__`` attribute might also + be set, which is the path to any compiled version of the code (e.g. byte-compiled file). The file does not need to exist to set this attribute; the path can simply point to where the compiled file would exist (see :pep:`3147`). - It is also appropriate to set ``__cached__`` when ``__file__`` is not + Note that ``__cached__`` may be set even if ``__file__`` is not set. However, that scenario is quite atypical. Ultimately, the - loader is what makes use of ``__file__`` and/or ``__cached__``. So + loader is what makes use of the module spec provided by the finder + (from which ``__file__`` and ``__cached__`` are derived). So if a loader can load from a cached module but otherwise does not load from a file, that atypical scenario may be appropriate. |