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-142349: Move all lazy-imports-by-hand to use the new lazy keyword by pablogsal · Pull Request #144894 · python/cpython

Conversation

@pablogsal

@pablogsal pablogsal commented Feb 16, 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: Implement PEP 810 – Explicit lazy imports #142349

Sorry, something went wrong.

Uh oh!

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

All reactions
@pablogsal
pythongh-142349: Move all lazy-imports-by-hand to use the new lazy ke…
280757b
…yword
@bedevere-app bedevere-app Bot mentioned this pull request Feb 16, 2026
Implement PEP 810 – Explicit lazy imports #142349
Closed
@pablogsal

pablogsal commented Feb 16, 2026

Copy link
Copy Markdown
Member Author

@Yhg1s @DinoV WDYT?

All reactions

Sorry, something went wrong.

Uh oh!

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

@DavidCEllis

DavidCEllis commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Maybe worth noting that this would make -X lazy_imports=none unusable as most of the standard library will fail to import.

All reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal

pablogsal commented Feb 17, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

Maybe worth noting that this would make -X lazy_imports=none unusable as most of the standard library will fail to import.

Not fail to import, it will just be slower (if properly done).

All reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal

pablogsal commented Feb 17, 2026

Copy link
Copy Markdown
Member Author

To be honest I am not super into this idea myself, but wanted to show how it looks for debate

All reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal pablogsal added the DO-NOT-MERGE label Feb 17, 2026
@DavidCEllis

DavidCEllis commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Maybe worth noting that this would make -X lazy_imports=none unusable as most of the standard library will fail to import.

Not fail to import, it will just be slower

You changed this to add (if properly done), but to be clear.

A couple of examples with this PR:

$ ./python -X lazy_imports=none -c "import re"
...
ImportError: cannot import name 'partial' from partially initialized module 'functools' (most likely due to a circular import) (/home/david/src/cpython/Lib/functools.py)
$ ./python -X lazy_imports=none -c "import collections"
...
ImportError: cannot import name 'deepcopy' from partially initialized module 'copy' (most likely due to a circular import) (/home/david/src/cpython/Lib/copy.py)

I do think in general the new lazy import form looks better, but it will need to be done with care (are there already tests to make sure the stdlib is still importable under lazy_imports=none?).

All reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal

pablogsal commented Feb 17, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

You changed this to add (if properly done), but to be clear.

Yeah :) What I wanted to say is that in theory just moving these imports to top level should not fail (as opposed to imports in with statements or try/excepts) if properly done

A couple of examples with this PR:

Thanks for the examples! Some extra passes need to be done if we want it because as it is test are failing anyway :(

(are there already tests to make sure the stdlib is still importable under lazy_imports=none?).

Not (yet) since we haven't started to use the feature around.

Thanks a lot for the point, this is indeed an important aspect that we must not overlook here or elsewhere!

All reactions

Sorry, something went wrong.

Uh oh!

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

@DavidCEllis

DavidCEllis commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

I picked re and collections as examples as they frequently end up somewhere in the chain of imports. functools is another that fails. I wasn't kidding when I said most of the standard library!

All reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal

pablogsal commented Feb 17, 2026

Copy link
Copy Markdown
Member Author

Indeed :(

I think I will close this. We need to approach this much slower and thinking how to check we don't fall into that. Thanks for the comments!

DavidCEllis, AlexWaygood, and johnslavik reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal pablogsal closed this Feb 17, 2026
@Yhg1s Yhg1s added the topic-lazy-imports label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 will be requested when the pull request is marked ready for review kumaraditya303 is a code owner
@vsajip vsajip Awaiting requested review from vsajip vsajip will be requested when the pull request is marked ready for review vsajip is a code owner
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 will be requested when the pull request is marked ready for review FFY00 is a code owner
@orsenthil orsenthil Awaiting requested review from orsenthil orsenthil will be requested when the pull request is marked ready for review orsenthil is a code owner
@cjw296 cjw296 Awaiting requested review from cjw296 cjw296 will be requested when the pull request is marked ready for review cjw296 is a code owner
@JelleZijlstra JelleZijlstra Awaiting requested review from JelleZijlstra JelleZijlstra will be requested when the pull request is marked ready for review JelleZijlstra is a code owner
@AlexWaygood AlexWaygood Awaiting requested review from AlexWaygood AlexWaygood will be requested when the pull request is marked ready for review AlexWaygood is a code owner
@StanFromIreland StanFromIreland Awaiting requested review from StanFromIreland StanFromIreland will be requested when the pull request is marked ready for review StanFromIreland is a code owner
@encukou encukou Awaiting requested review from encukou encukou will be requested when the pull request is marked ready for review encukou is a code owner
@hauntsaninja hauntsaninja Awaiting requested review from hauntsaninja hauntsaninja will be requested when the pull request is marked ready for review hauntsaninja is a code owner
@ethanfurman ethanfurman Awaiting requested review from ethanfurman ethanfurman will be requested when the pull request is marked ready for review ethanfurman is a code owner
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland will be requested when the pull request is marked ready for review erlend-aasland is a code owner
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou will be requested when the pull request is marked ready for review lysnikolaou is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner will be requested when the pull request is marked ready for review AA-Turner is a code owner
@giampaolo giampaolo Awaiting requested review from giampaolo giampaolo will be requested when the pull request is marked ready for review giampaolo is a code owner
@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger will be requested when the pull request is marked ready for review rhettinger is a code owner
@ambv ambv Awaiting requested review from ambv ambv will be requested when the pull request is marked ready for review ambv is a code owner
@gaogaotiantian gaogaotiantian Awaiting requested review from gaogaotiantian gaogaotiantian will be requested when the pull request is marked ready for review gaogaotiantian is a code owner
@barneygale barneygale Awaiting requested review from barneygale barneygale will be requested when the pull request is marked ready for review barneygale is a code owner
@gpshead gpshead Awaiting requested review from gpshead gpshead will be requested when the pull request is marked ready for review gpshead is a code owner
@cmaloney cmaloney Awaiting requested review from cmaloney cmaloney will be requested when the pull request is marked ready for review cmaloney is a code owner
@jaraco jaraco Awaiting requested review from jaraco jaraco will be requested when the pull request is marked ready for review jaraco is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw will be requested when the pull request is marked ready for review warsaw is a code owner
@terryjreedy terryjreedy Awaiting requested review from terryjreedy terryjreedy will be requested when the pull request is marked ready for review terryjreedy is a code owner
@tomasr8 tomasr8 Awaiting requested review from tomasr8 tomasr8 will be requested when the pull request is marked ready for review tomasr8 is a code owner
@pfmoore pfmoore Awaiting requested review from pfmoore pfmoore will be requested when the pull request is marked ready for review pfmoore is a code owner
@pradyunsg pradyunsg Awaiting requested review from pradyunsg pradyunsg will be requested when the pull request is marked ready for review pradyunsg is a code owner
@pganssle pganssle Awaiting requested review from pganssle pganssle will be requested when the pull request is marked ready for review pganssle is a code owner
@ericvsmith ericvsmith Awaiting requested review from ericvsmith ericvsmith will be requested when the pull request is marked ready for review ericvsmith is a code owner
@picnixz picnixz Awaiting requested review from picnixz picnixz will be requested when the pull request is marked ready for review picnixz is a code owner
@1st1 1st1 Awaiting requested review from 1st1 1st1 will be requested when the pull request is marked ready for review 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov asvetlov will be requested when the pull request is marked ready for review asvetlov is a code owner
@willingc willingc Awaiting requested review from willingc willingc will be requested when the pull request is marked ready for review willingc is a code owner
@savannahostrowski savannahostrowski Awaiting requested review from savannahostrowski savannahostrowski will be requested when the pull request is marked ready for review savannahostrowski is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently will be requested when the pull request is marked ready for review ericsnowcurrently is a code owner
@brettcannon brettcannon Awaiting requested review from brettcannon brettcannon will be requested when the pull request is marked ready for review brettcannon is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan will be requested when the pull request is marked ready for review ncoghlan is a code owner
@isidentical isidentical Awaiting requested review from isidentical isidentical will be requested when the pull request is marked ready for review isidentical is a code owner
@Eclips4 Eclips4 Awaiting requested review from Eclips4 Eclips4 will be requested when the pull request is marked ready for review Eclips4 is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

DO-NOT-MERGE topic-lazy-imports

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

@pablogsal @DavidCEllis @Yhg1s
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.