Python 3.15+sysfunction
sys.get_lazy_imports()
modules
Returns the current lazy-import mode as a string: 'normal' or 'all'.
Syntax
sys.get_lazy_imports()
The default mode is 'normal': only imports explicitly marked with the lazy keyword are lazy. The mode is changed by sys.set_lazy_imports, the -X lazy_imports flag and the PYTHON_LAZY_IMPORTS variable, so checking it in code is useful when the program's behaviour depends on how it was launched.
Examples
import sys
print(sys.get_lazy_imports()) # → normal
See also
Open in the full glossarydocs.python.orgReport an inaccuracy