Skip to content

gh-142349: Fill gaps in lazy import documentation - #162386

Open
pablogsal wants to merge 3 commits into
python:mainfrom
pablogsal:docs/lazy-imports-audit-20261121
Open

pablogsal wants to merge 3 commits into
python:mainfrom
pablogsal:docs/lazy-imports-audit-20261121

Conversation

@pablogsal

@pablogsal pablogsal commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

The lazy import docs omit some resolution rules and runtime controls. This adds those details and corrects the AST, bytecode and API help.

PRs #161762 and #161716 cover __lazy_import__.

Related to #142349.

@read-the-docs-community

read-the-docs-community Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

@pablogsal
pablogsal requested review from encukou and hugovk November 21, 2026 13:28

Copy link
Copy Markdown
Member Author

CC @hugovk @encukou @AA-Turner

@pablogsal

Copy link
Copy Markdown
Member Author

I don't think there are more gaps in the docs after this

@warsaw

warsaw commented Nov 21, 2026

Copy link
Copy Markdown
Member

Good to see this, and I'll do a review hopefully soon. I've been looking into updates to the import system docs in the language reference manual, so thanks for adding those.

Comment thread Doc/builtins/functions.rst Resolved
Comment thread Lib/pydoc_data/topics.py Resolved
Comment thread Doc/tutorial/modules.rst Resolved
Comment thread Doc/library/importlib.rst Resolved
Comment thread Doc/library/types.rst Resolved
@pablogsal
pablogsal requested a review from hugovk November 24, 2026 15:18
Comment thread Doc/library/importlib.rst
Comment on lines +1474 to 1478
The :class:`importlib.util.LazyLoader` example below does the module search
immediately and delays only module execution. It creates a module object in
:data:`sys.modules` before execution.

The example below shows how to implement lazy imports::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two "example below", let's drop the old intro bit.

Suggested change
The :class:`importlib.util.LazyLoader` example below does the module search
immediately and delays only module execution. It creates a module object in
:data:`sys.modules` before execution.
The example below shows how to implement lazy imports::
The :class:`importlib.util.LazyLoader` example below does the module search
immediately and delays only module execution. It creates a module object in
:data:`sys.modules` before execution::

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir needs backport to 3.15 bugs and security fixes skip news topic-lazy-imports type-feature A feature request or enhancement

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants