Skip to main content

cached property method decorator

Project description

cachedprop

Python 3.6 Python 3.7 Build Status

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


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 py3

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 Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page