propcache

0.4.1 · active · verified Sat Mar 28

propcache is a Python library that provides accelerated implementations of cached properties, enhancing performance for property caching in Python 3.9 and above. The current version is 0.4.1, with a release cadence that includes regular updates and bug fixes.

Warnings

Install

Imports

Quickstart

This example demonstrates how to use propcache's cached_property to cache the result of an expensive computation in a class property.

from propcache import cached_property

class MyClass:
    def __init__(self, value):
        self._value = value

    @cached_property
    def computed_property(self):
        # Expensive computation
        return self._value * 2

obj = MyClass(10)
print(obj.computed_property)  # Outputs: 20

view raw JSON →