-
Notifications
You must be signed in to change notification settings - Fork 48
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
ENH: implement lazy imports for optional dependencies #250
Conversation
98d9b22
to
b0f26e9
Compare
b0f26e9
to
18e1bd1
Compare
18e1bd1
to
f82d3a1
Compare
this now includes changes for dask, recently added with #185 (ping @chrishavlin) |
f82d3a1
to
4102e48
Compare
this is now based on #272 |
4102e48
to
5328cc1
Compare
@jzuhone @chrishavlin can I request your reviews on this ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious about the doctests bit, but otherwise looks good.
4410e37
to
ea899d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Left a couple minor comments.
One additional question -- why'd you put the unyt_arrayConverter
class in _mpl_array_converter.__init__.py
instead of a new module, _mpl_array_converter.py
?
ea899d0
to
de818a2
Compare
I can't remember. I would guess I went through several iterations and that form was the first one with which I managed to pass tests, for some reason. Now I agree that a module is better than a mono-module package, and I've checked that it does not in fact break anything, so let's roll with that. update: it seems that the simpler form breaks on Python 3.8 (see https://github.com/yt-project/unyt/pull/250/checks), so I'll revert this change |
de818a2
to
fed3312
Compare
…ib import even when it's available
fed3312
to
d62f1c6
Compare
This is another step to resolve #27
Overall, this gets us to a state where core dependencies (numpy + sympy) are responsible for at least 50-60 % of unyt's import time.
This refactor is similar to my work in yt yt-project/yt#3935
It allows for optional dependencies to never be imported before they are actually requested by users, reducing unyt's own startup time when heavy optional dependencies are installed.
Making matplotlib a true "on-demand" import took a little more work, but now
import unyt
doesn't causematplotlib
to be imported too when available, reducing the startup time by about 15% to 25% with respect to unyt 2.9.2 (on my machine).