Lazy loading has landed!

Lazy loading has just landed!

Please try out the latest main branch, and let us know if you uncover any issues. This change should improve import speed and, more importantly, allow interactive exploration of the entire namespace.

import skimage as ski
ski.filters.gaussian(...)  # This now works!

If you’d prefer all modules to be imported on load, you can set the environment variable EAGER_IMPORT=1.

5 Likes

This looks great! Are you planning to do this for SciPy? If not, I am happy to do it. I quickly looked at the scikit-image PR and seems like there is not much to do :slight_smile: Or do you advice to wait a bit?

When I originally proposed this, I don’t think the reception from SciPy was very warm; perhaps because we got burnt in that project with trying this early on. But, perhaps worth having a discussion about it now that we have a proof of concept on the table?

The evidence will be stronger once we’ve released scikit-image and have a few months of use under our belt, which should allow us to surface any complaints.

Having said that, we haven’t had any complaints about it on the napari side. :smiley:

For what is worth, I would support this. It’s IMO a good idea and we should be able to do it.
This is so convenient for users to have this, especially newcomers.

I also think it’s good for the respective “brands”. NumPy has np and we should have the equivalent for SciPy, scikit-image, etc.

1 Like