Assuming we have a function that updates a bunch of internal values within a class like so:
class MyClass:
def __init__():
self.counter = 0
self.condition_1 = True
self.condition_2 = False
def update():
if self.condition_1:
if self.condition_2:
self.counter += 2
# return or not?
else:
self.counter += 1
# return or not?
else:
self.counter -= 1
# return or not?
Would the update function be executed faster with or without a return statement within it (after updating variables)? Or would it be 100% the same? (unlikely for me)
I know this sounds like a trivial/dumb question to ask without context, but consider that this function is being called repeatedly thousands of times so slight increase in performance within the function can have a large impact on how fast the whole program takes to execute.
In my real program, the conditions within the update function are very complex and more nested; the program processes a lot of data as well.