Please describe your wishes and possible alternatives to achieve the desired result.
Right now anndata imports most available optional dependencies at import time. We do this since most optional deps are array types that we can support in anndata and we need to register each of the relevant classes to our singledispatch methods.
https://github.com/scverse/anndata/blob/main/anndata/compat/__init__.py
However, this can slow import and isn't always necessary. We could swap this out with dask's approach. This is very similar to singledispatch, but waits until a lazily registered object is first seen to add it to the registry. These matches are made based on name, so no import is required.
A downside of this is that I don't see a good way to use the same symbol for typing and lazy registration, as we do now. Maybe something with if TYPE_CHECKING?
Please describe your wishes and possible alternatives to achieve the desired result.
Right now anndata imports most available optional dependencies at import time. We do this since most optional deps are array types that we can support in anndata and we need to register each of the relevant classes to our
singledispatchmethods.https://github.com/scverse/anndata/blob/main/anndata/compat/__init__.py
However, this can slow import and isn't always necessary. We could swap this out with
dask's approach. This is very similar tosingledispatch, but waits until a lazily registered object is first seen to add it to the registry. These matches are made based on name, so no import is required.A downside of this is that I don't see a good way to use the same symbol for typing and lazy registration, as we do now. Maybe something with
if TYPE_CHECKING?