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 ! :::: _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com