[Python-Dev] Switch statement (original) (raw)

Guido van Rossum guido at python.org
Fri Jun 23 22:21:16 CEST 2006


On 6/23/06, Phillip J. Eby <pje at telecommunity.com> wrote:

Hm. Did I miss something, or did we just solve builtin lookup optimization? The only problem I see is that currently you can stick a new version of 'len()' into a module from outside it, shadowing the builtin. Under this scheme (of making all read-only names in a module become closure variables), such an assignment would change the globals, but have no effect on the module's behavior, which would be tied to the static definitions created at import time.

Or we could arrange for such assignments to be dynamically illegal. We could have some provision whereby any name that's known to the compiler to be a built-in, and for which the compiler can't see an explicit assignment, is implicitly made static. This would make it a run-time error if "import *" were to redefine such a name. The module object would have to know which names are static and disallow assignments to these. It would also have to export dict as a proxy that disallows such assignments. I think it can be made to work.

I do think this would require static names as well as static expressions. This is definitely still in the brainstorm phase!

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list