M.-A. Lemburg wrote:
Having a simple switch statement would enable writing very fast parsers in Python -
Instead of having one function call per token, you'd only have a single dict lookup.
BTW, has anyone in this thread actually read the PEP 275 ?
I haven't actually seen any use cases outside of parsers branching on a constant token. When I see stacked elif clauses, the condition almost always includes some computation (perhaps only ".startswith" or "in" or a regex match), and there are often cases which look at a second variable.
If speed for a limited number of cases is the only advantage, then I would say it belongs in (at most) the implementation, rather than the language spec.