Registry / devops / lazyasd

lazyasd

JSON →
library0.1.4pypypi✓ verified 84d ago

Lazy & self-destructive tools for speeding up module imports in Python. Current version 0.1.4. Low release cadence, supports Python 2.7+ and 3.x.

pip install lazyasd
INSTALL
IMPORT
SIG · LAZYASD
L
lazyasd
devopspythonv0.1.4
harness data pending
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)
Debug
Known issues
gotchaLazyObject does not support attribute access until the module is actually loaded. Attempting to access attributes before any triggering access may raise AttributeError.
fix
Ensure the lazy object is accessed (e.g., call a function) to trigger module loading before relying on other attributes.
affects: all
gotchaThe lazyobject decorator creates a self-destructive object: after first call, the name is replaced with the result. If the decorated function raises an exception, the object remains, but subsequent calls may behave unexpectedly.
fix
Wrap the function body in try-except to ensure cleanup on error, or avoid using lazyobject for code that may fail.
affects: all
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.
fix
Upgrade 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.
fix
Update 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.

Agent activity
4 hits · last 30 days
node
4
Resources
lazyasd — pip install lazyasd · libregistry