cached_property_based_on#

sunpy.util.cached_property_based_on(attr_name)[source]#

A decorator to cache the value of a property based on the output of a different class attribute.

This decorator caches the values of getattr(instance, method) and prop(instance). When the decorated property is accessed, getattr(instance, method) is called. If this returns the same as its cached value, the cached value of prop is returned. Otherwise both meth and prop are recomputed, cached, and the new value of prop is returned.

Parameters:

attr_name – The name of the attribute, on which changes are checked for. The actual attribute is accessed using getattr(attr_name, instance).

Notes

The cached value of meth(instance) is stored under the key meth.__name__.