{"id":27917,"library":"lazyasd","title":"lazyasd","description":"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.","status":"maintenance","version":"0.1.4","language":"python","source_language":"en","source_url":"https://github.com/xonsh/lazyasd","tags":["lazy","import","speed","module","self-destructive"],"install":[{"cmd":"pip install lazyasd","lang":"bash","label":"default"}],"dependencies":[],"imports":[{"note":"No common wrong pattern.","symbol":"LazyObject","correct":"from lazyasd import LazyObject"},{"note":"No common wrong pattern.","symbol":"lazyobject","correct":"from lazyasd import lazyobject"},{"note":"No common wrong pattern.","symbol":"LazyDict","correct":"from lazyasd import LazyDict"},{"note":"No common wrong pattern.","symbol":"load_module_in_background","correct":"from lazyasd import load_module_in_background"}],"quickstart":{"code":"from lazyasd import LazyObject, lazyobject\n\n# Lazy import via LazyObject\nnp = LazyObject({}, module='numpy')\n# Use np only when accessed; numpy is imported on first use.\n# Example: print(np.array([1,2,3]))\n\n# Self-destructive module function (runs once, then deletes itself)\n@lazyobject\ndef some_expensive_setup():\n    # do heavy initialization\n    return 'done'\n# After first call, some_expensive_setup is replaced with its return value.\nprint(some_expensive_setup)\n","lang":"python","description":"Lazy imports and self-destructive objects to speed up module loading."},"warnings":[{"fix":"Ensure the lazy object is accessed (e.g., call a function) to trigger module loading before relying on other attributes.","message":"LazyObject does not support attribute access until the module is actually loaded. Attempting to access attributes before any triggering access may raise AttributeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Wrap the function body in try-except to ensure cleanup on error, or avoid using lazyobject for code that may fail.","message":"The 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Upgrade to latest version: pip install --upgrade lazyasd","cause":"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.","error":"AttributeError: module 'lazyasd' has no attribute 'LazyObject'"},{"fix":"Update lazyasd: pip install --upgrade lazyasd. Ensure correct spelling: lazyobject.","cause":"The decorator `lazyobject` was added in a later version (0.1.0+). Using an older version or misspelling.","error":"ImportError: cannot import name 'lazyobject' from 'lazyasd'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}