#firstly
pip install cached_property
#and then:
from cached_property import cached_property
class A(object):
def __init__(self):
self.value = 0
# @cached_property
# def new_value(self):
# self.value += 10
# return self.value
@property
def new_value(self):
self.value += 10
return self.value
a = A()
print a.new_value
print a.new_value
print a.new_value
print a.new_value
#you can see the differences between them .