Is there an efficiency difference between using and in an if statement and using multiple if statements? In other words, is something like
if expr1 == expr2 and
Any differences in speed between using and
and nested ifs will be minimal. You are barking up the wrong tree. Consider this tree:
if oftenTrueCondition and rarelyTrueCondition:
compared with
if rarelyTrueCondition and oftenTrueCondition:
So, unless the first condition must be evaluated first (it is a guard to stop the next expression from crashing or doing something silly/expensive), consider swapping the order of evaluation.