syntax difference
bart4858 at gmail.com
bart4858 at gmail.com
Wed Jun 20 14:41:23 EDT 2018
The actual interpreter code is irrelevant. Switch would be a feature of the language being interpreted, not of the interpreter.
If the task is to match an expression X against a variety of values, then expressing that as a switch means the interpreter /could/ use a jump table (of labels within the byte code), rather than execute a chain of X==Y tests within byte code. So, evaluate X once then it could be a single byte code op.
At least, it will know that exactly the same X value is being tested. So you evaluate it once then keep it on the stack.
Think of Switch as another kind if hint.
--
Bart
More information about the Python-list
mailing list