class documentation

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

View In Hierarchy

A :func:`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. .. code-block:: python 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 If the class defines ``__slots__``, it must add ``_cache_{name}`` as a slot. Alternatively, it can add ``__dict__``, but that's usually not desirable. .. versionchanged:: 2.1 Works with ``__slots__``. .. versionchanged:: 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
Instance Variable slot_name Undocumented
def __delete__(self, obj: object): (source)

Undocumented

def __get__(self, obj: object, type: type = None) -> _T: (source)

Undocumented

def __init__(self, fget: t.Callable[[t.Any], _T], name: t.Optional[str] = None, doc: t.Optional[str] = None): (source)

Undocumented

def __set__(self, obj: object, value: _T): (source)

Undocumented

__module__ = (source)

Undocumented

__name__ = (source)

Undocumented

slot_name = (source)

Undocumented