Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
LazyObject
✓ from lazyasd import LazyObject
No common wrong pattern.
lazyobject
✓ from lazyasd import lazyobject
No common wrong pattern.
LazyDict
✓ from lazyasd import LazyDict
No common wrong pattern.
load_module_in_background
✓ from lazyasd import load_module_in_background
No common wrong pattern.
Lazy imports and self-destructive objects to speed up module loading.
from lazyasd import LazyObject, lazyobject
# Lazy import via LazyObject
np = LazyObject({}, module='numpy')
# Use np only when accessed; numpy is imported on first use.
# Example: print(np.array([1,2,3]))
# Self-destructive module function (runs once, then deletes itself)
@lazyobject
def some_expensive_setup():
# do heavy initialization
return 'done'
# After first call, some_expensive_setup is replaced with its return value.
print(some_expensive_setup)
Errors
Common errors & fixes
AttributeError: module 'lazyasd' has no attribute 'LazyObject'
Version older than 0.1.0 or incorrect installation. This error may occur if the library is not properly installed or a very old version is used.
fixUpgrade to latest version: pip install --upgrade lazyasd
ImportError: cannot import name 'lazyobject' from 'lazyasd'
The decorator `lazyobject` was added in a later version (0.1.0+). Using an older version or misspelling.
fixUpdate lazyasd: pip install --upgrade lazyasd. Ensure correct spelling: lazyobject.
Upgrade
Version history
0.1.4latest on PyPI · released Mar 21, 2018
Audit
Dependencies
No dependency data recorded yet.