cached property method decorator
Project description
cachedprop
cached property method decorator
Demo
from cachedprop import cpd
class LabRat:
def __init__(self) -> None:
self._hp = None
def expensive_hp_getter(self) -> int:
...
@cpd
def hp(self):
return self.expensive_hp_getter()
rat = LabRat()
print(rat.hp) # expensive_hp_getter is called, value gets "cached", prints value
print(rat.hp) # prints "cached" value only.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cachedprop-0.1.0.tar.gz
(1.6 kB
view hashes)
Built Distribution
Close
Hashes for cachedprop-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7827459f269b7c8d649c9c88441b452fabc32cdb2747aed500394b22a74a5fae |
|
MD5 | a62bb0e3eb359da26f7ae4c1c2490786 |
|
BLAKE2b-256 | 15e2dece11e6b4f37c99cf85407b1531e8b64d3072e4a70ce04fe952e65a8cb7 |