Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b4e38e

Browse files
committed
Mention __cached__ in the import ref.
1 parent 533f1ed commit 4b4e38e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Doc/reference/import.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,11 @@ Loaders must satisfy the following requirements:
353353
* The loader may set the ``__file__`` attribute of the module. If set, this
354354
attribute's value must be a string. The loader may opt to leave
355355
``__file__`` unset if it has no semantic meaning (e.g. a module loaded from
356-
a database).
356+
a database). If ``__file__`` is set, it may also be appropriate to set the
357+
``__cached__`` attribute which is the path to any compiled version of the
358+
code (e.g. byte-compiled file). The file does not need to exist to set this
359+
attribute; the path can simply point to whether the compiled file would
360+
exist (see :pep:`3147`).
357361

358362
* The loader may set the ``__name__`` attribute of the module. While not
359363
required, setting this attribute is highly recommended so that the

0 commit comments

Comments
 (0)