Skip to content

zmievsa/cached_classproperty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cached_classproperty

cached_property for class properties instead of instance properties


Test Coverage PyPI Supported Python versions

Installation

pip install cached_classproperty

Usage

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

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.

About

cached_property for class properties instead of instance properties

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published