| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I'm about to board a flight, but I think this cuts nearly 50% off the import time for inspect |
Sorry, something went wrong.
|
(But this is possibly a redundant optimisation if it turns out that inspect needs to depend on ast more heavily due to PEP 649 anyway? Not sure) |
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.
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 ast itself imports a bunch of stuff, so I'm not sure how much deferring the other imports helps if we can't defer the ast import. It might just make the code uglier for no apparent gain. I'll play around a bit when I get a chance; maybe now we've deferred the re import in ast things might have changed... |
Sorry, something went wrong.
I ended up looking at this on Python 3.15a5 main and indeed the ast is used heavily in annotationlib, which is itself imported from inspect in a way that cannot be made lazy. We could still lazy import tokenize and re, especially once the lazy import PR lands. |
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 re and tokenize modules. (ast module cannot be made lazy anymore given PEP 649). |
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 ty work from the sidelines, really excited about how it's progressing 👏 ) |
Sorry, something went wrong.
|
Opened ##144756 in case you have bandwidth for review @AlexWaygood 🙏 |
Sorry, something went wrong.
|
#144756 is merged, let's close this. Thanks all! |
Sorry, something went wrong.
|
Thank you both!! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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