An open API service indexing awesome lists of open source software.

https://github.com/zmievsa/cached_classproperty

cached_property for class properties instead of instance properties
https://github.com/zmievsa/cached_classproperty

Last synced: 3 months ago
JSON representation

cached_property for class properties instead of instance properties

Awesome Lists containing this project

README

          

# cached_classproperty

cached_property for class properties instead of instance properties

---



Test


Coverage


PyPI


Supported Python versions

## Installation

```bash
pip install cached_classproperty
```

## Usage

Similarly to `functools.cached_property`, these properties get executed exactly once on access.

```python
from cached_classproperty import cached_staticproperty, cached_classproperty

class Foo:
@cached_staticproperty
def my_staticproperty():
...

@cached_classproperty
def my_classproperty(cls):
...
```

`cached_classproperty` can be inherited and can re-execute for every inherited class just like `cached_property`. `cached_staticproperty`, on the other hand, executes exactly once even if inherited. It is also lighter and faster than `cached_classproperty`.