Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Property caching

Project Description

Cached version of property

Written and used by the folks at Yola to support our free website builder.


  • cached_property - stores results of decorated methods in decorated object (in _cached_properties attribute)
  • class_cached_property - stores results of decorated methods in the class of decorated object (in _class_cached_properties attribute). All instances will share cached value.
  • clear_property_cache - deletes cached value (works for object cached properties only)
  • set_property_cache - explicitly sets property cache (works for object cached properties only)
  • is_property_cached - allows to check whether property was cached or not (works for object cached properties only)


from property_caching import (cached_property,

class Dummy:
    def foo(self):
        return self.service.expensive_operation()

    def bar(self):
        # this value will only be cached if it doesn't evaluate to false:
        return self.service.expensive_operation2()

    def service(self):
        return expensive_service_initialization()

d = Dummy()   # calculates result and stores it in d._cached_properties   # uses cached value

clear_property_cache(d, 'foo')   # clears cache for property `foo`
set_property_cache(d, 'foo', 42) # explicitly set cache for property `foo`

d2 = Dummy()  # re-calculates value of `foo` but uses cached service


Install development requirements:

pip install -r requirements.txt

Run the tests with:

python test

Release History

This version
History Node


History Node


History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(3.9 kB) Copy SHA256 Hash SHA256
Source None Mar 29, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting