-
Notifications
You must be signed in to change notification settings - Fork 516
Description
It is a fairly common problem (see, e.g. issue #770) that people assume that import dateutil
will automatically import all of dateutil
'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 module sys.modules
or something to implement the equivalent to a module-level __getattr__
.