{"categories":[{"label":"Python Modules","url":"https://skillfed.io/packages/category/software-development-libraries-python-modules/21"}],"enrichment":{"capability":"Defers module loading and ImportErrors until a module or callable is actually used, avoiding initialization costs for optional dependencies.","skillfed_tags":["import-optimization","lazy-loading","legacy-python"],"use_cases":["Reduce startup time in CLI tools or servers that load heavy optional libraries like numpy or scipy only in certain code paths.","Delay ImportError for missing optional dependencies until they are actually needed, allowing graceful fallback or user-friendly error messages.","Defer initialization of large machine-learning or scientific libraries in applications where they may not be used in every execution.","Mark optional submodules as lazy at package initialization so downstream code can import them normally while they remain lazy.","Wrap callable functions to defer their module loading until the function is actually invoked."],"what_it_does":"lazy_import provides functions to defer the loading of Python modules and callables until they are actually used. Instead of importing a module immediately, you register it as lazy, and the actual import and initialization happen only when you access an attribute or call the function. This is useful for optional dependencies that have heavy loading times or memory footprints\u2014you pay the cost only if the module is needed.\n\nThe package works by wrapping modules and callables without using import hooks, so it has minimal impact on other code in the same session. When a lazy module is registered in sys.modules, any subsequent import of that module in the same session gets the lazy version until it is fully loaded. Once an attribute is accessed, the module loads in place and behaves like a normal module thereafter.","worth_installing":"No. The package is abandoned (last updated January 2018, no commits since July 2023) and targets Python 2.7 and early Python 3 versions. Compatibility with modern Python is uncertain. The GPLv3 copyleft license restricts use in proprietary projects. Unless you are maintaining legacy Python 2.7 code or have specific compatibility constraints, modern alternatives or native Python features (e.g., importlib, __getattr__ on modules) are safer choices."},"id":"lazy-import","links":{"html":"https://skillfed.io/packages/lazy-import","md":"https://skillfed.io/packages/lazy-import.md","pypi":"https://pypi.org/project/lazy-import/"},"maintenance":{"status":"abandoned"},"meta":{"latest_release":"2018-01-22","license_spdx":null,"license_treatment":"copyleft","name":"lazy-import","python_support":"unspecified","summary":"A module for lazy loading of Python modules"},"popularity":{"monthly_downloads":92001,"position":13490,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"0.2.2"}
