zope.deferredimport allows you to perform imports of names that will only be resolved when used in the code. This utility library helps improve application startup time and manage potential circular dependencies by making imports lazy. The current version is 6.1.1, and it receives updates as part of the broader Zope Foundation ecosystem.
pip install zope.deferredimportVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `deferredImport` to lazily load symbols into a target module. The symbols are only imported from their source module when they are first accessed, helping to reduce initial load times. It also shows how attempts to access non-existent deferred items will correctly raise an `AttributeError`.
Upgrade Python to 3.10+ or pin `zope.deferredimport<6` in your project's dependencies.
Thoroughly test deferred imports. During debugging, inspect `sys.modules` and the target module's `__dict__` to verify that the source modules are correctly loaded and contain the expected symbols.
Ensure that code paths requiring deferred symbols are genuinely lazy. Defer imports only for components that are not always needed during application startup or during module initialization.
If `from ... import *` behavior is desired, explicitly define or append the names of the deferred symbols to the `__all__` list in the module where `deferredImport` is used.
No dependency data recorded yet.