Skip to main content

cached property method decorator

Project description


Python 3.6 Python 3.7 Build Status

cached property method decorator


from cachedprop import cpd

class LabRat:
    def __init__(self) -> None:
        self._hp = None
    def expensive_hp_getter(self) -> int:
    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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cachedprop, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size cachedprop-0.1.0-py3-none-any.whl (2.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cachedprop-0.1.0.tar.gz (1.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page