[Python-Dev] Re: switch statement
Jim Jewett
jimjjewett at gmail.com
Tue Apr 26 00:20:04 CEST 2005
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.
-jJ
More information about the Python-Dev
mailing list