We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2005434 commit e86de6bCopy full SHA for e86de6b
Doc/reference/simple_stmts.rst
@@ -948,7 +948,13 @@ Python versions older than 3.15 while leveraging lazy imports on 3.15+::
948
import pathlib # loaded lazily
949
950
Relative imports are resolved to their absolute name before the lookup, so
951
-the sequence must always contain fully qualified module names.
+the sequence must always contain fully qualified module names::
952
+
953
+ # In mypackage/mymodule.py
954
+ __lazy_modules__ = ["mypackage"]
955
956
+ from . import utils # loaded lazily: resolves to mypackage
957
+ import json # loaded eagerly (not in __lazy_modules__)
958
959
Imports inside functions, class bodies, or
960
:keyword:`try`/:keyword:`except`/:keyword:`finally` blocks are always eager,
0 commit comments