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

Consider lazy loader for heavier imports #4648

Closed
dabacon opened this issue Nov 9, 2021 · 2 comments
Closed

Consider lazy loader for heavier imports #4648

dabacon opened this issue Nov 9, 2021 · 2 comments
Assignees
Labels
kind/health For CI/testing/release process/refactoring/technical debt items

Comments

@dabacon
Copy link
Collaborator

dabacon commented Nov 9, 2021

Description of the issue

There are a couple of packages that Cirq uses that have slow import times, but are not heavily used. These include a lot of subpackages of scipy, like scipy.optimize and scipy.stats. Currently we lazily import these before their use in order to avoid these being imported in the global init of cirq. See #4643 for example.

However @MichaelBroughton suggested that we do this the way that TensorFlow does this, using the following class
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/util/lazy_loader.py#L23

We should consider doing this, and if so we do we should also test the LazyLoader class.

@dabacon dabacon added the kind/health For CI/testing/release process/refactoring/technical debt items label Nov 9, 2021
@MichaelBroughton
Copy link
Collaborator

MichaelBroughton commented Nov 9, 2021

Some more discussion in #4643

@dabacon
Copy link
Collaborator Author

dabacon commented Nov 10, 2021

Implemented in #4653

@dabacon dabacon closed this as completed Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/health For CI/testing/release process/refactoring/technical debt items
Projects
None yet
Development

No branches or pull requests

2 participants