Here is an example:
import statistics
from functools import cached_property
class DataSet:
def __init__(self, sequence_of_numbers):
self._data = sequence_of_numbers
@cached_property
def stdev(self):
return statistics.stdev(self._data)
@cached_property
def variance(self):
return statistics.variance(self._data)
What is the easiest way to list cached properties?
I have a solution:
import inspect
import functools
list_of_cached_properties_names = [
name for name, value in inspect.getmembers(DataSet)
if isinstance(value, functools.cached_property)
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With