@cached_property
Project description
Cached Property
Provides a thread safe @cached_property
decorator that can be used
in place of the built in @property
decorator for properties that are
expensive to compute or that aren't expected to change over the lifetime
of an instance.
Usage
>>> from cached_property import cached_property
>>> class MyClass:
... @cached_property
... def prop(self):
... return 2 ** 42
...
>>> instance = MyClass()
>>> "prop" in instance.__dict__
False
>>> instance.prop # value computed and cached
4398046511104
>>> "prop" in instance.__dict__
True
>>> instance.prop # cached value returned directly
4398046511104
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
Built Distribution
Close
Hashes for com.wyattbaldwin.cached_property-1.0.post2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c807fa7266a47708e3af251dcccb856687830e09e462fd69c9aa8cddee8618e3 |
|
MD5 | 52b62a026583dc4a4523ef8219e96c5f |
|
BLAKE2b-256 | ec24ef9c184cc099d2375c1ebc74cc8573ae907e78589791af0ea01f02f78ca8 |
Close
Hashes for com.wyattbaldwin.cached_property-1.0.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef5c30bf5d3c103a6a2c55e234515d08a4f941155fb1f64c7f92736a119280b3 |
|
MD5 | 05e77e1eafe6e529b03e69ea37f7b839 |
|
BLAKE2b-256 | b21638365245b20885081f67a2f6766130b5f1d059719b06ccfdcbe612c0f74d |