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