-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Speed up tqdm.auto import when not in an IPython notebook #955
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
Conversation
Is this guaranteed in all versions? |
Awesome idea! Thank you for the PR! As @casperdcl says, need to double check whether |
If that renaming occurred, then it would break the existing code too. |
I asked on https://gitter.im/jupyter/jupyter and got this answer from @MSeal:
|
hmm we go a little further and do |
Probably equivalent in forward compatibility.
As I understand it, there's not meant to be a way to distinguish if you're in a ipykernel that's being controlled by a notebook or not. I don't believe there was an explicit emphasis on hiding if you're in ipython or ipykernel, but there certainly isn't any helper. |
Any updates on this? |
will likely be in |
Is it possible to include this in v4.47.0 now that issue #993 has been created? I am having to use my branch for performance reasons in another project (http://git.ligo.org/emfollow/gwcelery). |
Yes, it'll be in #993... |
Would be required to extend queue len > 2
In tqdm.auto, look for `IPython` in `sys.modules` rather than explicitly importing it. If we are in an IPython notebook, then IPython will have already been imported. If we are not in an IPython notebook, then importing IPython will take almost half a second. Here are import times on a 2018 MacBook Pro with an SSD. Before this patch: $ time python -c 'from tqdm.auto import tqdm' real 0m0.474s user 0m0.278s sys 0m0.142s After this patch: $ time python -c 'from tqdm.auto import tqdm' real 0m0.069s user 0m0.041s sys 0m0.020s Fixes tqdm#709.
92ec6e6
to
4e8f74c
Compare
Codecov Report
@@ Coverage Diff @@
## devel #955 +/- ##
==========================================
+ Coverage 85.41% 87.04% +1.62%
==========================================
Files 22 21 -1
Lines 1303 1250 -53
Branches 219 213 -6
==========================================
- Hits 1113 1088 -25
+ Misses 169 141 -28
Partials 21 21 |
Thank you! |
tqdm/tqdm#955 has been merged and is now in a release.
In tqdm.auto, look for
IPython
insys.modules
rather than explicitly importing it. If we are in an IPython notebook, then IPython will have already been imported. If we are not in an IPython notebook, then importing IPython will take almost half a second.Here are import times on a 2018 MacBook Pro with an SSD. Before this patch:
After this patch:
Fixes #709.