-
Notifications
You must be signed in to change notification settings - Fork 479
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
Lazy-load dateutil submodules? #771
Comments
@pganssle have you considered using lazy_import for this?
to
|
I'm not willing to add any new dependencies. It shouldn't be too difficult to implement, though. |
Looks like lazy_import is GPL, so it's also an incompatible license. Our implementation should be a "clean room" implementation not based on theirs. |
Co-authored-by: Paul Ganssle <paul@ganssle.io>
This uses PEP 562 to implement lazy loading of submodules in dateutil (dateutilGH-771).
This uses PEP 562 to implement lazy loading of submodules in dateutil (dateutilGH-771).
This uses PEP 562 to implement lazy loading of submodules in dateutil (dateutilGH-771).
Done via #1007 |
It is a fairly common problem (see, e.g. issue #770) that people assume that
import dateutil
will automatically import all ofdateutil
's sub-modules. Currently we don't do this because we want to be as lazy as possible about imports.We'll need to profile it, but I think there is a "best of both worlds" option here, where in
dateutil.__init__
we define lazy-loaded modules, so that the first time you invoke, e.g.dateutil.tz
dateutil.tz
will be imported in the background, and subsequent queries come from a cache.For Python 3.7+, I think the best / fastest way to do this is to use module-level
__getattr__
and__dir__
implementations, but for pre-Python 3.7, we may need to do something fancy and modulesys.modules
or something to implement the equivalent to a module-level__getattr__
.The text was updated successfully, but these errors were encountered: