From 0fbd075447f21316ecbb7c649649deda25fca879 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 27 Nov 2026 15:42:15 +0100 Subject: [PATCH 1/2] Link to the PEP once, point other links to the lazy-imports section --- Doc/library/sys.rst | 8 ++++---- Doc/library/types.rst | 2 +- Doc/reference/simple_stmts.rst | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 48424381ac5003..730dba263af10b 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -954,7 +954,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only :attr:`module.__lazy_modules__`. This is the default mode. * ``"all"``: Make all eligible module-scope imports potentially lazy. - See also :func:`set_lazy_imports` and :pep:`810`. + See also :func:`set_lazy_imports` and :ref:`lazy-imports`. .. versionadded:: 3.15 @@ -1538,7 +1538,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only In future versions of Python, these may be removed, and/or additional extras may be added. - See also :func:`set_lazy_imports` and :pep:`810`. + See also :func:`set_lazy_imports` and :ref:`lazy-imports`. .. versionadded:: 3.15 @@ -1848,7 +1848,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only In addition to the mode, lazy imports can be controlled via the filter provided by :func:`set_lazy_imports_filter`. - See also :func:`get_lazy_imports` and :pep:`810`. + See also :func:`get_lazy_imports` and :ref:`lazy-imports`. .. versionadded:: 3.15 @@ -1885,7 +1885,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only This is an advanced feature intended for specialized users who need fine-grained control over lazy import behavior. - See also :func:`get_lazy_imports_filter` and :pep:`810`. + See also :func:`get_lazy_imports_filter` and :ref:`lazy-imports`. .. versionadded:: 3.15 diff --git a/Doc/library/types.rst b/Doc/library/types.rst index cd7c2605fc6b61..03443bba428a3c 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -362,7 +362,7 @@ Standard names are defined for the following types: .. versionadded:: 3.15 - .. seealso:: :pep:`810` + .. seealso:: :ref:`lazy-imports` .. method:: resolve() diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst index d0a6df28cae413..42566e620210e3 100644 --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -921,7 +921,9 @@ If an error occurs during module loading (such as :exc:`ImportError` or used, not at the import statement itself. The sections below describe name resolution and runtime controls. -See :pep:`810` for the full specification of lazy imports. + +.. seealso:: :pep:`810` provides the rationale and initial specification + for lazy imports. .. versionadded:: 3.15 From a10389084f44124ffd09adc37969c77b39aae1bf Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 27 Nov 2026 16:18:56 +0100 Subject: [PATCH 2/2] Note that `resolve()` doesn't cache --- Doc/library/types.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 03443bba428a3c..7e0714a5e0fdcc 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -373,6 +373,10 @@ Standard names are defined for the following types: lazy import json json = globals()["json"].resolve() + Each call to :func:`!resolve` call does a fresh import. + The proxy itself does not store :func:`!resolve`'s result, + relying on the import mechanism to use :attr:`sys.modules` + to reuse modules that have already been imported. .. class:: GetSetDescriptorType