lazy_loader python 子包以及函数懒加载框架, 内部处理上是基于了importlib.import_module 进行动态加载
包含的特性
- 可以确保子模块对于用户的可见行,不引起而外的开销
- 允许外部库在使用的时候被加载,提升导入时间
说明
此包在kedro 的datasets 模块中使用比较多,基本上每个datasets 扩展都能看到身影 
比如 polars 中dataset 的处理 __init__.py
from typing import Any
 
import lazy_loader as lazy
 
# https://github.com/pylint-dev/pylint/issues/4300#issuecomment-1043601901
CSVDataset: Any
EagerPolarsDataset: Any
LazyPolarsDataset: Any
 
__getattr__, __dir__, __all__ = lazy.attach(
    __name__,
    submod_attrs={
        "csv_dataset": ["CSVDataset"],
        "eager_polars_dataset": [
            "EagerPolarsDataset",
        ],
        "lazy_polars_dataset": ["LazyPolarsDataset"],
    },
) 
参考资料
https://github.com/kedro-org/kedro-plugins 
https://scientific-python.org/specs/spec-0001/ 
https://github.com/scientific-python/lazy-loader










