@@ -125,10 +125,11 @@ at the top level but may only use a subset of them in any given run. The deferre
125125loading reduces startup latency without requiring code restructuring or conditional
126126imports scattered throughout the codebase.
127127
128- When a lazy import eventually fails (for example, if the module does not exist),
129- Python raises the exception at the point of first use rather than at import time.
130- The traceback includes both the location where the name was accessed and the
131- original import statement, making it straightforward to diagnose the problem.
128+ In the case where loading a lazily imported module fails (for example, if the
129+ module does not exist), Python raises the exception at the point of first use
130+ rather than at import time. The associated traceback includes both the location
131+ where the name was accessed and the original import statement, making it
132+ straightforward to diagnose & debug the failure.
132133
133134For cases where you want to enable lazy loading globally without modifying source
134135code, Python provides the :option: `-X lazy_imports <-X> ` command-line option and
@@ -162,12 +163,12 @@ containing the names of all modules that have been lazily imported but not yet
162163loaded. The proxy type itself is available as :data: `types.LazyImportType ` for
163164code that needs to detect lazy imports programmatically.
164165
165- There are some restrictions on where ``lazy `` can appear . Lazy imports are only
166- permitted at module scope; using ``lazy `` inside a function, class body, or
167- ``try ``/``except ``/``finally `` block raises a :exc: `SyntaxError `. Star imports
168- cannot be lazy (``lazy from module import * `` is a syntax error), and future
169- imports cannot be lazy either (``lazy from __future__ import ... `` raises
170- :exc: `SyntaxError `).
166+ There are some restrictions on where the ``lazy `` keyword can be used . Lazy
167+ imports are only permitted at module scope; using ``lazy `` inside a function,
168+ class body, or ``try ``/``except ``/``finally `` block raises a :exc: `SyntaxError `.
169+ Star imports cannot be lazy (``lazy from module import * `` is a syntax error),
170+ and future imports cannot be lazy either (``lazy from __future__ import ... ``
171+ raises :exc: `SyntaxError `).
171172
172173.. seealso :: :pep:`810` for the full specification and rationale.
173174
0 commit comments