lazy-loader
Makes it easy to load subpackages and functions on demand.
Decision gist · record as of 2026-08-14
Yes. Lazy-loader is production-stable, actively maintained, permissively licensed, and has low install friction. Install it if you are building a package with many submodules or optional dependencies and want to defer loading. It is not necessary for simple applications, but it is a standard tool in the scientific Python ecosystem.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Python >= 3.9 required; Python 3.11.9+ or 3.12.3+ recommended to avoid a known race condition in the standard library.
- Installation is straightforward with low friction; the package is actively maintained and supports Python 3.9 through 3.14.
- The fact sheet recommends Python 3.11.9+ or 3.12.3+ to avoid a known race condition in earlier versions.
License · maintenance · safety
BSD-3-Clause (permissive) — Licensed under BSD-3-Clause (permissive), allowing use in both open-source and proprietary projects with minimal restrictions.
last release 2026-03-06 (161 days) · last repo commit 2026-07-06 · 208 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 32,093,369 downloads/mo, #781 on PyPI
Alternatives
Verify before relying
import lazy_loader as lazy
# In a package __init__.py:
__getattr__, __dir__, _ = lazy.attach(__name__, subpackages=['filters'])
# Or for external libraries:
sp = lazy.load('scipy')
sp.linalg.norm(...)- Whether lazy loading introduces measurable latency on first access compared to eager imports in typical workflows.
- Compatibility with all major type checkers and IDEs beyond the static stub workaround mentioned.
- Actual performance gains in startup time for large packages with many submodules.
What it is and what it does
Lazy-loader is a utility that defers the import of subpackages and external libraries until they are first accessed. It works by intercepting attribute access on a module and loading the requested subpackage or function only when needed. This is useful for two main scenarios: allowing package authors to expose internal subpackages without paying the import upfront, and letting applications load optional dependencies only when their functionality is actually used.
The package provides two main APIs: `lazy.attach` for setting up lazy loading within a package's internal structure (replacing explicit imports in `__init__.py`), and `lazy.load` for lazily importing external libraries. It also supports version constraints on optional dependencies, raising errors only if a required version is not met and the dependency is accessed. Type checking is supported through `.pyi` stub files.
Use it for
- Organize package internals so subpackages are visible in the public API without incurring import overhead during initialization.
- Make optional dependencies transparent: load them only when their functionality is used, with version constraints enforced at access time.
- Support development and testing workflows by setting EAGER_IMPORT=1 to disable lazy loading and catch missing imports early.
- Improve IDE and type-checker support by using stub files to define lazy-loaded imports statically.
- Defer loading of external libraries until they are actually accessed by user code.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Lazy-loader is production-stable, actively maintained, permissively licensed, and has low install friction. Install it if you are building a package with many submodules or optional dependencies and want to defer loading. It is not necessary for simple applications, but it is a standard tool in the scientific Python ecosystem.
Install
lazy-loader on PyPI
Before you install
Installation is straightforward with low friction; the package is actively maintained and supports Python 3.9 through 3.14. The fact sheet recommends Python 3.11.9+ or 3.12.3+ to avoid a known race condition in earlier versions.
Python >= 3.9 required; Python 3.11.9+ or 3.12.3+ recommended to avoid a known race condition in the standard library.
License in practice
Licensed under BSD-3-Clause (permissive), allowing use in both open-source and proprietary projects with minimal restrictions.
Quickstart
import lazy_loader as lazy
# In a package __init__.py:
__getattr__, __dir__, _ = lazy.attach(__name__, subpackages=['filters'])
# Or for external libraries:
sp = lazy.load('scipy')
sp.linalg.norm(...)
Verify before relying
- Whether lazy loading introduces measurable latency on first access compared to eager imports in typical workflows.
- Compatibility with all major type checkers and IDEs beyond the static stub workaround mentioned.
- Actual performance gains in startup time for large packages with many submodules.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepackaging |
| Maintenance | Actively maintained 161 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 32,093,369 / month, #781 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9 |
Evidence: lazy_loader-0.5-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “lazy import on demand”
- lazy-loaderLazy-loader defers the import of subpackages and external libraries…
- zope.deferredimportDefers module imports until they are actually used, optionally…
- lazy-importsDefers loading of module attributes and their dependencies until…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also lazy-import · lazy-imports · apipkg · lazy · lazy-model · lazyasd · lml · Lazify · proxy_tools · atpublic