mardi 15 décembre 2015

Is the python "elif" compiled differently from else: if?

I know in languages such as C/C++, Java or C#, (C# example)the else if statement is syntactic sugar, in that it's really just a one else statement followed by an if statement.

else if (conition(s)) { ...

is equal to

else {
    if (condition(s)) { ...
}

However, in python, there is a special elif statement. I've been wondering if this is just shorthand for developers or if there is some hidden optimization python can do because of this, such as be interpreted faster? But this wouldn't make sense to me, as other languages would be doing it too then (such as JavaScript). So, my question is, in python is the elif statement just shorthand for the developers to use or is there something hidden that it gains through doing so?

Aucun commentaire:

Enregistrer un commentaire