[Python-Dev] Re: Dynamic nested scopes
Fri, 03 Nov 2000 11:46:59 +0100
Moshe Zadka wrote:
> On Thu, 2 Nov 2000, Guido van Rossum wrote:
> > I think Python 3000 ought to use totally static scoping. That will
> > make it possible to do optimize code using built-in names!
> Isn't that another way of saying you want the builtin names to be
> part of the language definition? Part of today's method advantages
> is that new builtins can be added without any problems.
Wouldn't it be more Python-like to provide the compiler with
a set of known-to-be-static global name bindings ?
A simple way of avoiding optimizations like these:
def f(x, str=str):
return str(x) + '!'
would then be to have the compiler lookup "str" in the globals()
passed to it and assign the found value to the constants of the
function, provided that "str" appears in the list of
known-to-be-static global name bindings (perhaps as optional
addition parameter to compile() with some reasonable default
Python Pages: http://www.lemburg.com/python/