because i'm a statistician, when i write some code I'm quite concerned about it's efficiency, and now I can't get if there is one of the two following coding styles that's more efficient of the other (I'll show them in python):
def fun(args):
out= False
if control(args):
out= True
if second_control(args):
out= True
return out
or maybe:
def fun(args):
if control(args):
return True
if second_control(args):
return True
return False
of course I know I can do both controls whit a 'and' operator, but let's stick on the code above: I always thought that return points break the function and save time, but I tried the code you can see and I found that over 10000 iteration the first one is generally faster, over 1000000 iterations the second one is faster instead.
could someone explain me why does this happen? in fact I'm not even sure my tests are trustworthy.