Skip to content

Commit bd6342a

Browse files
committed
gh-142349: Link to import hooks and trim lazy import version notes
1 parent 249ed55 commit bd6342a

5 files changed

Lines changed: 22 additions & 138 deletions

File tree

‎Doc/builtins/functions.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2421,7 +2421,7 @@ are always available. They are listed here in alphabetical order.
24212421
resolution.
24222422

24232423
You can replace :func:`__import__` through an assignment to
2424-
``builtins.__import__``. Import hooks (see :pep:`302`) usually provide a
2424+
``builtins.__import__``. :ref:`Import hooks <import-hooks>` usually provide a
24252425
simpler way to customize imports. A replacement can cause problems for code
24262426
that expects the default import implementation.
24272427
Do not replace :func:`__import__` unless import hooks cannot supply the

‎Doc/library/importlib.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,9 +1467,9 @@ To import a Python source file directly from a path, use the following recipe::
14671467
Implementing lazy imports
14681468
'''''''''''''''''''''''''
14691469

1470-
Python 3.15 adds :ref:`lazy imports <lazy-imports>` through the
1471-
:keyword:`lazy` keyword. This language feature delays the module search
1472-
and execution until the first use of the imported name.
1470+
Use the :keyword:`lazy` keyword for an explicit :ref:`lazy import <lazy-imports>`.
1471+
Python delays the module search and execution until the first use of the
1472+
imported name.
14731473

14741474
The :class:`importlib.util.LazyLoader` example below does the module search
14751475
immediately and delays only module execution. It creates a module object in

‎Doc/reference/import.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ import machinery.
264264
directly, whereas now they return module specs which *contain* loaders.
265265
Loaders are still used during import but have fewer responsibilities.
266266

267+
.. _import-hooks:
268+
267269
Import hooks
268270
------------
269271

‎Doc/tutorial/modules.rst‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ use of the imported name. For example, in a new interpreter session::
8585
>>> fibo.fib(10) # Loads the module, then calls fib().
8686
0 1 1 2 3 5 8
8787

88-
The ``lazy`` keyword is available in Python 3.15 and later.
8988
Lazy imports are permitted only at module scope and outside
9089
:keyword:`try`/:keyword:`except`/:keyword:`finally` blocks.
9190

‎Lib/pydoc_data/topics.py‎

Lines changed: 16 additions & 133 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)