gh-117865: Defer several imports in inspect.py#119526
gh-117865: Defer several imports in inspect.py#119526AlexWaygood wants to merge 1 commit intopython:mainfrom
Conversation
|
I'm about to board a flight, but I think this cuts nearly 50% off the import time for |
|
(But this is possibly a redundant optimisation if it turns out that |
|
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.
Right -- but |
I ended up looking at this on Python 3.15a5 main and indeed the We could still lazy import |
|
@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 |
I'm a bit snowed under with work on ty right now -- feel free to pick this up if you'd like to! |
I'm happy to! I'll try to cherry-pick your commit to preserve your authorship. (watching the |
|
Opened ##144756 in case you have bandwidth for review @AlexWaygood 🙏 |
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