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.

Source Distribution

cachedprop-0.1.0.tar.gz (1.6 kB view hashes)

Uploaded Source

Built Distribution

cachedprop-0.1.0-py3-none-any.whl (2.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page