lundi 26 octobre 2020

Faster to include or exclude else

In Python which is faster for doing something useful (i.e. I don't care about the do something useless part) and why?

def function():
    if (condition):
        <do something useless>
        return
    <do something useful>
    return
def function():
    if (condition):
       <do something useless>
    else:
       <do something useful>
    return

Aucun commentaire:

Enregistrer un commentaire