Install & Compatibility
Where this runs
tested against v0.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
LazyProxy
✓ from lazify import LazyProxy
✗ from lazify import lazy
lazify
✓ from lazify import lazify
✗ from lazify import lazy
This quickstart demonstrates how to use `LazyProxy` for general lazy evaluation and the `@lazy` decorator for lazy attributes within classes. The decorated method or proxied function is only executed upon its first access, and its result is then cached for subsequent calls.
from lazify import LazyProxy, lazy
# Example 1: LazyProxy for deferred expression evaluation
def expensive_calculation():
print(" [TRACE] Performing expensive calculation inside function...")
return 42
print("Creating LazyProxy object...")
lazy_value = LazyProxy(expensive_calculation)
print("LazyProxy created, but calculation not yet performed.")
print(f"First access to lazy_value: {lazy_value}") # This triggers the calculation
print(f"Second access to lazy_value: {lazy_value}") # This uses the cached result
print("\n" + "-" * 20 + "\n")
# Example 2: @lazy decorator for lazy attributes in a class
class MyClass:
def __init__(self, initial_value):
self._initial_value = initial_value
@lazy
def processed_value(self):
print(f" [TRACE] Processing value {self._initial_value} with decorator...")
return self._initial_value * 2
obj = MyClass(10)
print("MyClass instance created, 'processed_value' not yet computed.")
print(f"First access to obj.processed_value: {obj.processed_value}") # This triggers the processing
print(f"Second access to obj.processed_value: {obj.processed_value}") # This uses the cached result
Debug
Known issues
gotchaThe `lazify` library has not been updated since June 2018. This indicates a lack of active maintenance, meaning it may not receive bug fixes, security patches, or new features. Users should be aware of potential long-term support issues.fixConsider evaluating alternatives if active development and support are critical for your project. If using `lazify`, thoroughly test its compatibility and behavior in your specific environment.
affects: <=0.4.0
gotchaWhile PyPI metadata states compatibility with Python 2 and 3, the last release was in 2018. There is a high likelihood of encountering compatibility issues with modern Python versions (e.g., Python 3.9+) that have introduced new syntax or removed deprecated features not present in 2018.fixTest `lazify` thoroughly with your target Python version. If issues arise, consider pinning an older, compatible Python version or refactoring your code to use an alternative lazy evaluation mechanism.
affects: 0.4.0 (with Python >= 3.9)
gotchaThis library focuses on lazy *evaluation* of expressions and object attributes, not on dynamically loading entire Python *modules* only when they are first used (a concept sometimes referred to as 'lazy import'). While related to performance, `lazify`'s scope is distinct from tools designed for deferred module loading.fixEnsure that `lazify` aligns with your specific use case. If you intend to lazily load modules, investigate Python's `importlib.util.LazyLoader` or other dedicated 'lazy import' solutions.
affects: All
Upgrade
Version history
0.4.0latest on PyPI · released Jun 14, 2018
Audit
Dependencies
No dependency data recorded yet.