GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-161708: Document the __lazy_import__ built-in function by RoryGlenn · Pull Request #161762 · python/cpython

Conversation

@RoryGlenn

@RoryGlenn RoryGlenn commented Nov 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Add a reference entry for __lazy_import__ and link it from the language reference for lazy imports. Give the table substitution its own comment explaining the column width and the link to the existing function target.

Validation: a fresh HTML build with warnings treated as errors, Sphinx lint 1.0.2 on both PR documentation files, whitespace checks, and rendered table/link checks passed. Rendering the published source with the same dependencies confirmed unchanged table HTML and anchors. Runtime tests were not rerun for this comment-only follow-up.

Public searches for 161708 and __lazy_import__, across open and closed issues and PRs, found no conflicting documentation contribution; #161716 changes the C docstring separately.

Prepared with OpenAI Codex assistance.

  • Issue: Document __lazy_import__ #161708

Validation

  • git diff --check f34ba9882b2bc06a45513d749b1ce421e74e376c HEAD -- Doc/builtins/functions.rst — exit 0
  • /cache/cpython-pr-161762-docs/bin/sphinx-lint --enable=default-role Doc/builtins/functions.rst Doc/reference/simple_stmts.rst — exit 0
  • make -C Doc html VENVDIR=/cache/cpython-pr-161762-docs JOBS=4 SPHINXOPTS='--fresh-env --write-all' — exit 0
  • python3 - <<'PY' from pathlib import Path root = Path('Doc/build/html') functions = (root / 'builtins/functions.html').read_text(encoding='utf-8') reference = (root / 'reference/simple_stmts.html').read_text(encoding='utf-8') assert 'id="func-lazy-import"' in functions assert 'id="lazy_import__"' in functions assert 'href="#func-lazy-import"' in functions assert '../builtins/functions.html#lazy_import__' in reference PY — exit 0
  • GIT_NO_LAZY_FETCH=1 git diff --check f34ba9882b2bc06a45513d749b1ce421e74e376c HEAD -- Doc/builtins/functions.rst — exit 0
  • `python3 - <<'PY'
    import html
    from pathlib import Path
    import re

root = Path('Doc/build/html')
functions = (root / 'builtins/functions.html').read_text(encoding='utf-8')
reference = (root / 'reference/simple_stmts.html').read_text(encoding='utf-8')
assert 'id="func-lazy-import"' in functions
assert 'id="lazy_import__"' in functions
assert 'href="#func-lazy-import"' in functions
assert '../builtins/functions.html#lazy_import__' in reference

table = functions.split('<table', 1)[1].split('', 1)[0]
cells = re.findall(r'<td\b.?', table, flags=re.DOTALL)
assert len(cells) == 4
assert 'href="#func-lazy-import"' in cells[3]
last_column = html.unescape(re.sub(r'<[^>]
>', '', cells[3]))
assert last_column.index('import()') < last_column.index('lazy_import()')
visible_text = html.unescape(re.sub(r'<[^>]*>', '', functions))
assert 'Use a substitution because' not in visible_text
PY` — exit 0

Prepared with AI assistance (Codex gpt-6.1-sol). Independent automated review passed for source tree 6f874ac7770b773a2de54fa77c721c894db06e2d. This is automated review. Upstream CI is pending until GitHub reports its result.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot] and JadenV15 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@RoryGlenn
pythongh-161708: Document the __lazy_import__ built-in function
f34ba98
@bedevere-app bedevere-app Bot mentioned this pull request Nov 10, 2026
Document __lazy_import__ #161708
Open
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Nov 10, 2026
@github-project-automation github-project-automation Bot added this to Docs PRs Nov 10, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Nov 10, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 10, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35791718 | 📁 Comparing f34ba98 against main (2f0e294)

  🔍 Preview build  

2 files changed
± builtins/functions.html
± reference/simple_stmts.html
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland
StanFromIreland reviewed Nov 10, 2026
View reviewed changes
Comment thread Doc/builtins/functions.rst
.. |func-range| replace:: ``range()``
.. |func-bytearray| replace:: ``bytearray()``
.. |func-bytes| replace:: ``bytes()``
.. |func-lazy-import| replace:: ``__lazy_import__()``

@StanFromIreland StanFromIreland Nov 10, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

But won't the target end up here? Why is this needed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@RoryGlenn RoryGlenn Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The replace:: line only supplies the displayed text, __lazy_import__(). The trailing _ in |func-lazy-import|_ makes that text link to .. _func-lazy-import:, just above the function definition.

I used the same pattern as range() and bytes() because it fits the existing grid. A direct :func: reference can reach the same function, as it does in the language reference, but its markup is too long for that cell with the current spacing. The substitution adds one line under __import__ and preserves the four-column layout.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@StanFromIreland StanFromIreland Nov 11, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Then please add a comment for that, rather than keep it under the other one.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@RoryGlenn
pythongh-161708: Document the __lazy_import__ built-in function
4d01f7f
Signed-off-by: Rory Glenn <[email protected]>
@RoryGlenn

RoryGlenn commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Automated contribution follow-up (Codex):

Separated func-lazy-import from the preceding substitution group and added its own source comment explaining the table width and the trailing _ link to the existing target. The generated table and anchors are unchanged; the fresh HTML build and Sphinx lint pass.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RoryGlenn
RoryGlenn marked this pull request as ready for review November 11, 2026 18:37
@RoryGlenn
RoryGlenn requested review from AA-Turner and willingc as code owners November 11, 2026 18:37
@bedevere-app bedevere-app Bot added the awaiting review label Nov 11, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T18:40:05.190981Z 4d01f7f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JadenV15
JadenV15 reviewed Nov 11, 2026
View reviewed changes
Comment thread Doc/builtins/functions.rst
named by *name*, not an individual member of that module.

If *globals* is omitted or ``None``, the caller's global namespace is used.
Otherwise, it must be a dictionary containing an ``__builtins__`` entry.

@JadenV15 JadenV15 Nov 11, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

sorry to nitpick, but 'an __builtins__ entry' -> 'a __builtins__ entry'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/builtins/functions.rst

The filter installed by :func:`sys.set_lazy_imports_filter` can force an
eager import. If the filter returns false, the function returns the
imported module instead of a lazy proxy.

@JadenV15 JadenV15 Nov 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

maybe specify that the eager module is types.ModuleType? (maybe unnecesssary)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@StanFromIreland StanFromIreland StanFromIreland left review comments
@willingc willingc Awaiting requested review from willingc willingc is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
+1 more reviewer
@JadenV15 JadenV15 JadenV15 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Docs PRs
Status: Todo

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@RoryGlenn @StanFromIreland @JadenV15
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.