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

Load imports lazily #551

Merged
merged 7 commits into from
Jul 10, 2022
Merged

Load imports lazily #551

merged 7 commits into from
Jul 10, 2022

Conversation

hakonanes
Copy link
Member

Description of the change

This PR introduces lazy imports of modules, following the specification in PEP 562.

The implementation in hyperspy/hyperspy#2850 helped a lot when figuring out a nice way to test lazy importing, thanks @ericpre!

Progress of the PR

Minimal example of the bug fix or new feature

Before this PR:

In [1]: %time import kikuchipy as kp
CPU times: user 7.65 s, sys: 556 ms, total: 8.21 s
Wall time: 7.54 s

After this PR:

In [1]: %time import kikuchipy as kp
CPU times: user 431 ms, sys: 164 ms, total: 596 ms
Wall time: 340 ms

Note that the import time of from kikuchipy.signals import EBSD does not change, as that import triggers all the imports in kikuchipy/signals/ebsd.py both before and after this PR.

For reviewers

  • The PR title is short, concise, and will make sense 1 year later.
  • New functions are imported in corresponding __init__.py.
  • New features, API changes, and deprecations are mentioned in the unreleased
    section in CHANGELOG.rst.
  • New contributors are added to release.py and .all-contributorsrc and the table
    is regenerated.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes added the enhancement New feature or request label Jul 10, 2022
@hakonanes hakonanes added this to the v0.7.0 milestone Jul 10, 2022
@hakonanes hakonanes merged commit fa61cb0 into pyxem:develop Jul 10, 2022
@hakonanes hakonanes deleted the adopt-lazy-imports branch July 10, 2022 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant