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-154675: reorganize some imports in importlib by brettcannon · Pull Request #154657 · python/cpython

Conversation

@brettcannon

@brettcannon brettcannon commented Jul 24, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: Improve import time of various stdlib modules #154675

Sorry, something went wrong.

Uh oh!

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

All reactions
@brettcannon
Use lazy imports in the top-level modules of importlib
12fbb96
@brettcannon
brettcannon requested review from FFY00, ericsnowcurrently, ncoghlan and warsaw as code owners July 24, 2026 22:59
@brettcannon brettcannon added skip issue skip news labels Jul 24, 2026
@brettcannon brettcannon self-assigned this Jul 24, 2026
@bedevere-app bedevere-app Bot added the awaiting core review label Jul 24, 2026
@hugovk hugovk changed the title Use lazy imports in the top-level modules of importlib gh-154675: Use lazy imports in the top-level modules of importlib Jul 25, 2026
@hugovk hugovk removed the skip issue label Jul 25, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jul 25, 2026
Improve import time of various stdlib modules #154675
Open
@hugovk

hugovk commented Jul 25, 2026

Copy link
Copy Markdown
Member

No objection to tidying the imports here, but I don't see much if any time saved here: _imp is a builtin and already loaded, warnings was already deferred.

We could get some good savings from importlib.resources (15ms -> 8ms) and importlib.metadata (10ms -> 7ms), but should also consider the backports.

All reactions

Sorry, something went wrong.

Uh oh!

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

StanFromIreland
StanFromIreland reviewed Jul 25, 2026
View reviewed changes
Comment thread Lib/importlib/util.py Resolved

Uh oh!

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

brettcannon added 2 commits July 27, 2026 12:41
@brettcannon
Revert making _imp lazy as it's a built-in module
457b553
@brettcannon
Merge branch 'main' into lazy-importlib
9318daa
@brettcannon

brettcannon commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

_imp is a builtin and already loaded

Good catch! I've reverted it.

warnings was already deferred.

True, but it bugged me enough that I've been wanting to make this change to the import since lazy imports were announced, so I consider it clean-up along with making the re-exporting more obvious.

We could get some good savings from importlib.resources (15ms -> 8ms) and importlib.metadata (10ms -> 7ms), but should also consider the backports.

I view that as a call for @jaraco to make as that's mostly their code.

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@brettcannon brettcannon changed the title gh-154675: Use lazy imports in the top-level modules of importlib gh-154675: reorganize some imports in importlib Jul 27, 2026
brettcannon added 2 commits July 27, 2026 12:48
@brettcannon
Reorder imports in importlib.abc for clarity and consistency
a71ce97
@brettcannon
Merge branch 'lazy-importlib' of github.com:brettcannon/cpython into …
1ffb9d6
…lazy-importlib
@brettcannon
brettcannon enabled auto-merge (squash) July 27, 2026 19:49
@brettcannon
brettcannon merged commit 0284ce8 into python:main Jul 27, 2026
47 checks passed

Uh oh!

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

@brettcannon
brettcannon deleted the lazy-importlib branch July 27, 2026 20:18
@bedevere-app bedevere-app Bot removed the awaiting core review label Jul 27, 2026
mbeijen pushed a commit to mbeijen/cpython that referenced this pull request Aug 14, 2026
@brettcannon @mbeijen
pythongh-154675: reorganize some imports in importlib (python#154657)
5f5b57c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk left review comments
@StanFromIreland StanFromIreland StanFromIreland left review comments
@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
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner

Uh oh!

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

Assignees

@brettcannon brettcannon

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.

3 participants

@brettcannon @hugovk @StanFromIreland
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.