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

Lazy loading through AST-mapped public API #62

Draft
wants to merge 1 commit into
base: pip-v-cmake-build
Choose a base branch
from

Conversation

Helveg
Copy link
Collaborator

@Helveg Helveg commented Dec 4, 2022

For user convenience pretty much every module is eager loaded onto the core NEST module. This has led to circular dependencies, code execution at import time, and long import times (about 1s for me).

Using the AST module we can scan all .py files for a module level __all__ declaration, and filter out the explicitly declared parts of the public API. We can then replace all dynamic module magic of the nest module by a fully spec-supported __getattr__ approach that loads modules as attributes are requested.

On my slow IO WSL it improved import times from 1s to 0.04s. On native Linux boxes an initial test showed that it would be more like a 0.8s to 8e-05 reduction of import nest

@github-actions
Copy link

Pull request automatically marked stale!

@github-actions github-actions bot added the stale label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant