mardi 31 octobre 2017

Is there a difference in efficiency between checking "if something is or else" and "if something isn't or else"

For example, right now I have a Python code that is used with Sympy and I have to check if an input is string and act according to that.

I am curious if it is different when you check:

if(True):
    Thing1()
else:
    Thing2()

Or:

if(False):
    Thing1()
else:
    Thing2()

For example with my code, I can check if something is a string/word and then turn it into a Sympy symbol and then assign it to an array, else assign it as an int to array. Or I can check if something ISN'T a string/word, and if it isn't, assign it as an int, else assign it as a Sympy symbol.

So my question is, is there a difference between checking "True or False" and "False or True"? Does it depend on input being more "Trues" than "Falses" or vice versa?

Aucun commentaire:

Enregistrer un commentaire