[Python-Dev] Switch statement (original) (raw)
M.-A. Lemburg mal at egenix.com
Fri Jun 16 10:29:51 CEST 2006
- Previous message: [Python-Dev] Switch statement
- Next message: [Python-Dev] Switch statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Ewing wrote:
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.
Good point.
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.
That would a very well hidden assignment of a "constantness" property to a symbol or expression. We'd also run into the problem of not knowing when to evaluate those case expressions, e.g. at function compile time, at run-time when first entering the switch statement, etc.
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Jun 16 2006)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
- Previous message: [Python-Dev] Switch statement
- Next message: [Python-Dev] Switch statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]