First: does it matter if i define an update function in a class or can i just do the following:
class foo(object):
def __init__(self):
self.a = 1
def f(self,):
self.a = self.a**2 - self.a - 6
return self.a
Second: is it more beneficial (save memory, runtime etc) to create a dummy variable, perform operations and use this to update my class variable, or does it not actually matter?
class foo(object):
def __init__(self):
self.a = 1
def f(self):
a = self.a
a = a**2-a-6
self.a = a
return self.a
In this trivial of an example, I know it doesn't matter, but as functions perform more operations, will it have any effect?