-
Notifications
You must be signed in to change notification settings - Fork 171
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
Enable lazy importing for external dependencies #1059
Comments
Really cool idea, TIL @ericmjl ! Lazy loading of imports, to me, would seem to be most beneficial if we are importing many optional submodules when importing a top-level package. In For optional imports such as the Also, is the lazy loading not meant to be implemented as top-level as possible? E.g. in the scenario that some function located within These are just my speculation and thoughts,though. Love to be corrected / educated on this! 😄 |
Great comments, @thatlittleboy! Thanks for thinking through the matter. I think you've got the right intuition w.r.t. what to lazy-import and in which files to do so. The only complication is the magical nature of Now that I've typed that all out, I think I will go in and modify pandas-flavor (for which I'm one of the maintainers) and make it do selective and lazy imports too. That will help with import times. |
Looks like it was never merged to dev? Any reasons not to do that now? |
@asmirnov69 it was mostly my fault for letting the PR go stale, therefore we didn't merge. Is this something you'd like to pick up? |
@ericmjl sure, if you still think it is important to have feature.
|
PR is open, original plan was changed to:
|
I'd like to propose that we use lazy imports for our external dependencies.
Currently, importing pyjanitor results in about ~1-2 seconds of delay. While insignificant for an interactive data exploration setting, it becomes a significant latency burden if there are projects that depend on
pyjanitor
.There is a SPEC for lazy importing, which means this idea is getting community traction in the SciPy world: https://scientific-python.org/specs/spec-0001/
There is also a tool for making lazy loading easy: https://pypi.org/project/lazy_loader/, thereby giving us a path towards lazy loading.
Would love to get thoughts from the dev team!
The text was updated successfully, but these errors were encountered: