| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Delayed import of traceback results in ~16% speedup. Issue python#109653
Sorry, something went wrong.
|
The tests fail because you can't import traceback when python is shutting down (but logging can still be called - e.g. in a del function of a global object) |
Sorry, something went wrong.
|
@jgeralnik oh, interesting, thank you! That would take me some time to figure out. So what you're saying is that this particular PR is doomed, we simply can't import traceback lazily? Or do you see some way around it? |
Sorry, something went wrong.
|
@AlexWaygood this ended up being harder than I thought, see comments above. Unless you have any suggestions I'll close this. |
Sorry, something went wrong.
It seems that new modules can't be imported during Python shutdown, and the logging module needs to be available during shutdown so I don't see a way around this. Closing. CC @AlexWaygood |
Sorry, something went wrong.
|
^Sorry for not getting to this earlier! Been unusually busy the last month or so :) Yeah, the stuff that goes on when Python is shutting down is... scary. Agree with the decision to close this one :) |
Sorry, something went wrong.
|
@AlexWaygood no worries at all, thanks for the comment and review on #114509 🤝 It was interesting to poke at stdlib for the first time (and realizing, as always, that things are more complicated than originally thought :-) ) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Lazy importing traceback module in logging improves the import time by ~15% on my machine (PGO-optimized build on Linux). Since traceback is used here to handle exceptions, these code paths should by definition better be exceptional so lazy loading makes sense.
In order to avoid performance impacts, I have used a trick proposed in a similar PR. Perhaps this trick is not necessary here though since as mentioned above these code paths should not be hot.
TODO: Fix the failing test.