Which one is better in terms of performance:
def check():
if (statement1 and
statement2 and
statement3):
return True
else:
return False
def doIt():
if check():
perform()
vs
def doIt():
if (statement1 and
statement2 and
statement3):
perform()
If (and only if) you’re having performance issues, time it yourself:
If you’re not having performance issues, follow The Zen of Python and remember what Donald Knuth said about premature optimisation.