class documentation

class cached_property(property, t.Generic[_T]):

View In Hierarchy

A property that is only evaluated once. Subsequent access returns the cached value. Setting the property sets the cached value. Deleting the property clears the cached value, accessing it again will evaluate it again.

class Example:
    @cached_property
    def value(self):
        # calculate something important here
        return 42

e = Example()
e.value  # evaluates
e.value  # uses cache
e.value = 16  # sets cache
del e.value  # clears cache

The class must have a __dict__ for this to work.

Changed in version 2.0: del obj.name clears the cached value.
Method __delete__ Undocumented
Method __get__ Undocumented
Method __init__ Undocumented
Method __set__ Undocumented
Instance Variable __module__ Undocumented
Instance Variable __name__ Undocumented
def __delete__(self, obj):

Undocumented

Parameters
obj:objectUndocumented
def __get__(self, obj, type=None):

Undocumented

Parameters
obj:objectUndocumented
type:typeUndocumented
Returns
_TUndocumented
def __init__(self, fget, name=None, doc=None):

Undocumented

Parameters
fget:t.Callable[[t.Any], _T]Undocumented
name:t.Optional[str]Undocumented
doc:t.Optional[str]Undocumented
def __set__(self, obj, value):

Undocumented

Parameters
obj:objectUndocumented
value:_TUndocumented
__module__ =

Undocumented

__name__ =

Undocumented