Uh oh!
There was an error while loading. Please reload this page.
gh-117865: Defer several imports in inspect.py - #119526
Conversation
AlexWaygood
commented
May 24, 2024
I'm about to board a flight, but I think this cuts nearly 50% off the import time for |
AlexWaygood
commented
May 24, 2024
(But this is possibly a redundant optimisation if it turns out that |
AlexWaygood
commented
May 29, 2024
I'll keep this on the back burner until it's decided where the new PEP-649 functions will go, and which modules they'll depend on |
JelleZijlstra
left a comment
There was a problem hiding this comment.
(This showed up in my list of review requests, so I want to clear it out even if it's a draft.)
I think we can apply the changes that don't affect ast. My current implementation of the PEP 649 functionality relies very heavily on ast, so it's likely we won't be able to defer that import.
AlexWaygood
commented
Jun 2, 2024
Right -- but |
danielhollas
commented
Jan 15, 2026
I ended up looking at this on Python 3.15a5 main and indeed the We could still lazy import |
danielhollas
commented
Feb 12, 2026
@AlexWaygood PEP810 has just landed. Are you planning to work on this PR in the near future? Per my previous comment, it could be a simple two-line change, just adding a lazy keyword in front of the |
AlexWaygood
commented
Feb 12, 2026
I'm a bit snowed under with work on ty right now -- feel free to pick this up if you'd like to! |
danielhollas
commented
Feb 12, 2026
I'm happy to! I'll try to cherry-pick your commit to preserve your authorship. (watching the |
danielhollas
commented
Feb 12, 2026
Opened ##144756 in case you have bandwidth for review @AlexWaygood 🙏 |
hugovk
commented
Mar 2, 2026
#144756 is merged, let's close this. Thanks all! |
AlexWaygood
commented
Mar 2, 2026
Thank you both!! |
Following 153b3f7, it is suddenly much more trivial to make the import of ast lazy in inspect.py. Once that's done, it also becomes worthwhile to make other imports lazy as well