[Python-Dev] Switch statement

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Jun 16 06:13:34 CEST 2006


M.-A. Lemburg wrote:

> My personal favorite is making the compiler
> smarter to detect the mentioned if-elif-else scheme
> and generate code which uses a lookup table for
> implementing fast branching.

But then the values need to be actual compile-time
constants, precluding the use of symbolic names,
values precomputed a run time, etc.

A new statement would allow us to simply document
that the case values are *assumed* constant, and
then the implementation could cache them in a dict
or whatever.

--
Greg


More information about the Python-Dev mailing list