-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
import time #11546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the analysis! It's really nice to see how the imports run.
Generally, I'm not sure if we want to move imports to local contexts to scrap of a few milliseconds from importing matplotlib. That's for someone else to decide @tacaswell . |
Note that support for directly loading from urls was added in #4256 with the following motivation:
which simply doesn't apply anymore today. I would thus like to suggest at least considering deprecating this functionality. Also, a simple inlining of the import did not clearly yield measurable improvements to import time in a quick experiment, so some measurements (not necessarily in depth) actually establishing the improvement post-inlining would be nice. |
There are actually two urllib.request uses:
Just removing or inlineing one does not give a performance benefit. |
I did try inlining both. Edit: Added "Needs confirmation" label as I simply cannot reproduce these numbers (in particular pyparsing imports very quickly for me, and I did try inlining the imports), but of course patches with performance numbers are still welcome. |
I played a bit with -Ximporttime and noticed that in certain cases, a module taking longer to import was actually due to the gc kicking in; thus, one should call gc.disable() before doing these benchmarks. |
I don't see an action on this, and it looks ephemeral, so I'm closing.... |
Here's an import profile created with Python 3.7's
importtime
and displayed with tuna:Looks like lazy-loading urllib.request would pay off. Likewise for pyparsing.
The text was updated successfully, but these errors were encountered: