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.

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

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page