Registry / development / memoized-property

memoized-property

JSON →
library1.0.3pypypi✓ verified 83d ago

A lightweight Python decorator for creating cached properties that compute their value only once per instance. Version 1.0.3, last updated in 2015. No active maintenance.

pip install memoized-property
INSTALL
IMPORT
SIG · MEMOIZED-PROPERTY
M
memoized-property
developmentpythonv1.0.3
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.

memoized_property
from memoized_property import memoized_property
from memoized import memoized_property
'memoized' is not the package name.

Basic usage of @memoized_property to cache a property.

from memoized_property import memoized_property class MyClass: @memoized_property def expensive(self): return [i for i in range(10000)] obj = MyClass() print(obj.expensive) # computed once print(obj.expensive) # cached
Debug
Known issues
gotchaThis decorator only works on classes (not standalone functions) and requires the property to be defined on an instance.
fix
Use @property combined with functools.lru_cache for more flexibility.
affects: <1.0.4
deprecatedLibrary is no longer maintained (last release 2015). Consider using @functools.cached_property (Python 3.8+) or @property + lru_cache.
fix
Replace import and decorator with cached_property from functools.
affects: >=1.0.0
Errors
Common errors & fixes
ImportError: No module named memoized_property
Package not installed or wrong Python environment.
fix
Run 'pip install memoized-property'.
AttributeError: 'function' object has no attribute '__memoized_property__'
Applied decorator to a method that is not a property (classmethod or staticmethod).
fix
Ensure decorator is used on a method that returns a value (like a property).
Upgrade
Version history
1.0.3latest on PyPI · released Sep 29, 2016
Audit
Dependencies

No dependency data recorded yet.

Agent activity
49 hits · last 30 days
node
42
OpenAI (training)
1
Resources
memoized-property — pip install memoized-property · libregistry