zope.deferredimport
zope.deferredimport allows you to perform imports names that will only be resolved when used in the code.
What it is and what it does
zope.deferredimport is a utility for delaying the actual import of module names until they are first used in code. Instead of importing a name at module load time, you declare it as deferred, and the import happens only when that name is accessed. This is useful for reducing startup time in large packages or for managing circular import dependencies.
The package also supports issuing deprecation warnings when a name is used, making it a tool for library maintainers to guide users away from old APIs without breaking existing code immediately. It works by creating module proxies that intercept attribute access and trigger the real import on demand. The package depends only on zope.proxy and supports current Python versions (3.10 through 3.14).
Use it for:
- Reduce module load time in large packages by deferring imports of rarely-used submodules until they are actually accessed.
- Issue deprecation warnings when users access old API names, guiding migration without immediate breakage.
- Manage circular import dependencies by deferring one side of the cycle until runtime.
- Create convenience re-exports in a package's __init__.py without paying the import cost upfront.
- Provide backward compatibility by keeping old names available but deprecated, with warnings on use.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Defers module imports until they are actually used, optionally issuing deprecation warnings when imported names are accessed.
Yes, if you need lazy imports or deprecation warnings in a library. Low install friction, active maintenance, no known vulnerabilities, and a focused scope make it reliable for its purpose. Verify ZPL-2.1 compatibility with your project's license before committing.
Install
zope-deferredimport on PyPI
pip
pip install zope-deferredimportuv
uv add zope-deferredimportpoetry
poetry add zope-deferredimportInstalling zope.deferredimport
Before you install
Low friction: pure Python wheel with a single runtime dependency (zope.proxy). Actively maintained with recent releases supporting Python 3.14 and dropping older versions; last commit 2026-02-16.
License in practice
Licensed under ZPL-2.1 (Zope Public License 2.1); license treatment marked unclear in metadata, so verify compatibility with your project's license policy before use.
Quickstart
from zope.deferredimport import deprecated
deprecated('old_name', 'module.new_name')
# old_name is now available but triggers a deprecation warning when accessed
Requires Python 3.10 or later.
Verify before relying
- Whether ZPL-2.1 is compatible with your project's licensing requirements (license_treatment is marked unclear).
- Specific use cases where deferred imports provide measurable performance or import-time overhead reduction.
- Whether zope.proxy's behavior and API are stable for your intended use.
Package facts
| License | ZPL-2.1 (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — zope.proxy |
| Maintenance | actively maintained — 179 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 393,748/month — #6,996 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: zope_deferredimport-6.1.1-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
zope.deprecationProvides a decorator and utilities to mark…
unclear · top 5,000 on PyPI
venusianVenusian defers decorator actions from import…
permissive · top 5,000 on PyPI
zope.dottednameConverts dotted name strings (like…
unclear · top 15,000 on PyPI
apipkgapipkg lets you define a package's exported…
permissive · top 5,000 on PyPI
LazifyLazify provides lazy evaluation utilities for…
permissive · top 15,000 on PyPI
zope.sizeProvides a standard interface and adapter for…
unclear · top 15,000 on PyPI
zope.sequencesortSorts sequences by multiple keys with support…
unclear · top 15,000 on PyPI
proxy_toolsProvides a lazy-evaluation proxy object that…
permissive · top 5,000 on PyPI
zope.exceptionsProvides general-purpose exception classes and…
unclear · top 15,000 on PyPI
zope.configurationZope.configuration provides an extensible…
unclear · top 5,000 on PyPI