@@ -95,7 +95,7 @@ applied.
9595The mechanism is also **granular **. It is introduced through explicit syntax on
9696individual imports, rather than a global flag or implicit setting. This allows
9797developers to adopt it incrementally, starting with the most
98- performance-sensitive areas of a codebase. As this feature is introduced to the
98+ performance-sensitive areas of a codebase. As this feature is introduced to the
9999community, we want to make the experience of onboarding optional, progressive, and
100100adaptable to the needs of each project.
101101
@@ -691,18 +691,18 @@ There are no known security vulnerabilities introduced by lazy imports.
691691How to Teach This
692692=================
693693
694- The new ``lazy `` keyword will be documented as part of the language standard.
694+ The new ``lazy `` keyword will be documented as part of the language standard.
695695
696- As this feature is opt-in, new Python users should be able to continue using the
696+ As this feature is opt-in, new Python users should be able to continue using the
697697language as they are used to. For experienced developers, we expect them to leverage
698698lazy imports for the variety of benefits listed above (decreased latency, decreased
699699memory usage, etc) on a case-by-case basis. Developers interested in the performance
700- of their Python binary will likely leverage profiling to understand the import time
700+ of their Python binary will likely leverage profiling to understand the import time
701701overhead in their codebase and mark the necessary imports as ``lazy ``. In addition,
702702developers can mark imports that will only be used for type annotations as ``lazy ``.
703703
704704Below is guidance on how to best take advantage of lazy imports and how to avoid
705- incompatibilities:
705+ incompatibilities:
706706
707707* When adopting lazy imports, users should be aware that eliding an import until it is
708708 used will result in side effects not being executed. In turn, users should be wary of
@@ -1168,7 +1168,7 @@ A: A lazily imported module does **not** appear in ``sys.modules`` until it's re
11681168 result = json.dumps({" key" : " value" }) # First use
11691169
11701170 print (' json' in sys.modules) # True
1171-
1171+
11721172 Reference Implementation
11731173========================
11741174
@@ -1186,7 +1186,7 @@ trade-offs that may be valuable for implementers to consider or for future refin
11861186Leveraging a Subclass of Dict
11871187-----------------------------
11881188
1189- Instead of updating the internal dict object to directly add the fields needed to support lazy imports,
1189+ Instead of updating the internal dict object to directly add the fields needed to support lazy imports,
11901190we could create a subclass of the dict object to be used specifically for Lazy Import enablement. This
11911191would still be a leaky abstraction though - methods can be called directly such as ``dict.__getitem__ ``
11921192and it would impact the performance of globals lookup in the interpreter.
@@ -1195,7 +1195,7 @@ Alternate Keyword Names
11951195-----------------------
11961196
11971197For this PEP, we decided to propose ``lazy `` for the explicit keyword as it felt the most familar to those
1198- already focused on optimizing import overhead. We also considered a variety of other
1198+ already focused on optimizing import overhead. We also considered a variety of other
11991199options to support explicit lazy imports. The most compelling alternates were ``defer `` and ``delay ``.
12001200
12011201
@@ -1227,13 +1227,13 @@ subtle bugs.
12271227Support of Import Cycles
12281228------------------------
12291229
1230- The initial PEP for lazy imports (PEP 690) contained support for eliminating most import cycles,
1231- but this meant that in some cases a codebase would no longer run successfully after disabling
1232- lazy imports. For the explicit lazy imports PEP we’ve decided not to add support for this use case.
1233- While codebases with heavily nested dependencies may benefit from this feature, supporting import
1234- cycles runs the risk of creating a dependency on lazy imports. As the intention of this PEP is to
1235- give users the power to opt in or opt out of lazy imports based on the specific needs within their
1236- codebases, we’ve decided not to implement this feature and instead prioritize backwards compatibility.
1230+ The initial PEP for lazy imports (PEP 690) contained support for eliminating most import cycles,
1231+ but this meant that in some cases a codebase would no longer run successfully after disabling
1232+ lazy imports. For the explicit lazy imports PEP we’ve decided not to add support for this use case.
1233+ While codebases with heavily nested dependencies may benefit from this feature, supporting import
1234+ cycles runs the risk of creating a dependency on lazy imports. As the intention of this PEP is to
1235+ give users the power to opt in or opt out of lazy imports based on the specific needs within their
1236+ codebases, we’ve decided not to implement this feature and instead prioritize backwards compatibility.
12371237
12381238Placing the ``lazy `` Keyword in the Middle of From Imports
12391239----------------------------------------------------------
@@ -1245,10 +1245,10 @@ is because ``from foo. lazy import bar`` is legal syntax.
12451245Placing the ``lazy `` Keyword at the End of Import Statements
12461246------------------------------------------------------------
12471247
1248- We discussed appending lazy to the end of import statements like such ``import foo lazy `` or
1249- ``from foo import bar, baz lazy `` but ultimately decided that this approach provided less clarity.
1250- For example, if multiple modules are imported in a single statement, it is unclear if the lazy binding
1251- applies to all of the imported objects or just a subset of the items.
1248+ We discussed appending lazy to the end of import statements like such ``import foo lazy `` or
1249+ ``from foo import bar, baz lazy `` but ultimately decided that this approach provided less clarity.
1250+ For example, if multiple modules are imported in a single statement, it is unclear if the lazy binding
1251+ applies to all of the imported objects or just a subset of the items.
12521252
12531253Returning a Proxy Dict from ``globals() ``
12541254------------------------------------------
0 commit comments