My problem simplified:
Let's assume that method_1 is a computationally heavy function. There's a possibility that it won't be necessary to call it at all when working with the instance of the class (so I don't want to put it in the inside the init-function). Then there is the other possibility that method_2 will be called multiple times and with my current solution in that case every time also the method_1 is called.
What would be easiest and most pythonic solution?
class MyClass:
def __init__(self, x, y):
self.__x = x
self.__y = y
def method_1(self)
# method that returns list which values vary depending on x and y
return some_list
def method_2(self, a)
# method that modifies and returns specific list element from some_list according to a
return do_modifications(self.method_1(), a)
def method_3(self, arg1, ...)
#some method
...