Skip to content
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

[WIP][RF] Use lazy loading #3056

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

skoudoro
Copy link
Member

@skoudoro skoudoro commented Feb 1, 2024

Proof of concept for adopting Scientific Python SPEC 1.

This has several advantages:

  • It exposes a nested namespace that behaves as a flat namespace. This avoids carefully having to import exactly the right combination of submodules, and allows interactive exploration of the namespace in an interactive terminal.
  • It avoids having to optimize for import cost. Currently, developers often move imports inside of functions to avoid slowing down importing their module. Lazy importing, when implemented through out a library, makes all imports cheap.
  • It provides direct access to submodules, avoiding local namespace conflicts. Instead of doing import dipy.reconst as reconst to avoid clobbering a local reconst, one can now import each library and access its members directly: import dipy; dipy.reconst.

Todo

  • Add CI run that uses EAGER_IMPORT=true env var to smoke out circular import issues
  • Convert all __init__.py

Feedbacks are welcomed

When this PR will be done, a follow-up PR will be created to simplify all tutorials import

@skoudoro skoudoro mentioned this pull request Apr 5, 2024
@skoudoro skoudoro linked an issue Apr 5, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Add lazy_loader
1 participant