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-118761: Add helper to ensure that lazy imports are actually lazy by JelleZijlstra · Pull Request #132614 · python/cpython

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Apr 16, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

This ensures that if we jump through some hoops to make sure something is imported
lazily, we don't regress on importing it.

I recently already accidentally made typing import warnings and annotationlib eagerly.

  • Issue: Improve import time of various stdlib modules #118761

Sorry, something went wrong.

Uh oh!

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

All reactions
@JelleZijlstra
pythongh-118761: Add helper to ensure that lazy imports are actually …
a55b37e
…lazy

This ensures that if we jump through some hoops to make sure something is imported
lazily, we don't regress on importing it.

I recently already accidentally made typing import warnings and annotationlib eagerly.
@JelleZijlstra
JelleZijlstra requested a review from AA-Turner April 16, 2025 20:43
@JelleZijlstra
JelleZijlstra requested review from AlexWaygood, brettcannon, ericsnowcurrently, ncoghlan and warsaw as code owners April 16, 2025 20:43
@bedevere-app bedevere-app Bot added the awaiting core review label Apr 16, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Apr 16, 2025
Improve import time of various stdlib modules #118761
Closed
@JelleZijlstra JelleZijlstra added the skip news label Apr 16, 2025
JelleZijlstra
JelleZijlstra commented Apr 16, 2025
View reviewed changes
Comment thread Lib/test/test_typing.py
"inspect",
"re",
"contextlib",
# "annotationlib", # TODO

@JelleZijlstra JelleZijlstra Apr 16, 2025

Copy link
Copy Markdown
Member 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.

#132596 will fix this

Sorry, something went wrong.

Uh oh!

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

All reactions
AA-Turner
AA-Turner approved these changes Apr 17, 2025
View reviewed changes

@AA-Turner AA-Turner left a comment

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.

Good idea!

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/test/support/import_helper.py Resolved

Uh oh!

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

Comment thread Lib/test/support/import_helper.py Resolved

Uh oh!

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

Comment thread Lib/test/support/import_helper.py Resolved

Uh oh!

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

Comment thread Lib/test/test_annotationlib.py Resolved

Uh oh!

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

Comment thread Lib/test/test_typing.py Resolved

Uh oh!

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

Comment thread Lib/test/test_typing.py Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Apr 17, 2025
@JelleZijlstra @AA-Turner
Apply suggestions from code review
a77577e
Co-authored-by: Adam Turner <[email protected]>
@JelleZijlstra
JelleZijlstra enabled auto-merge (squash) April 17, 2025 03:24
@JelleZijlstra
JelleZijlstra merged commit 39ee468 into python:main Apr 17, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Apr 17, 2025
@danielhollas danielhollas mentioned this pull request Apr 27, 2025
gh-118761: Add test_lazy_import for more modules #133057
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AA-Turner AA-Turner AA-Turner approved these changes
@AlexWaygood AlexWaygood Awaiting requested review from AlexWaygood AlexWaygood is a code owner
@brettcannon brettcannon Awaiting requested review from brettcannon brettcannon is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

skip news

Projects

None yet

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.

2 participants

@JelleZijlstra @AA-Turner
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.