[Python-3000] Python 3000 Status Update (Long!)

Alex Martelli aleaxit at gmail.com
Fri Jun 22 23:06:07 CEST 2007


On 6/22/07, Jean-Paul Calderone <exarkun at divmod.com> wrote:
   ...
> >> Calling abs() could change locals()['abs'], in which case a different
> >> function would be called the next time through.  You lookup 'abs' each
> >> time just in case it's changed.
> >>
> >
> >I can't think of a reason to allow that outside of something like an
> >obfuscated Python code contest. I'm sure there exists someone who thinks
> >differently...
>
> The perfectly good reason to allow it is that it is a completely
> predictable, unsurprising consequence of how the Python language
> is defined.
>
> Making a special case for the way names are looked up in a genexp
> means making it harder to learn Python and to understand programs
> written in Python.

Absolutely: it should NOT be about specialcasing genexp.  Rather, it
would be some new rule such as:
"""
If a built-in name that is used within the body of a function F is
rebound or unbound (in the builtins' module or in F's own module),
after 'def F' executes and builds a function object F', and before any
call to F' has finished executing, the resulting effect is undefined.
"""
This gives a future Python compiler a fighting chance to optimize
builtins' access and use -- quite independently from specialcases such
as genexps.  (Limiting the optimization to functions is, I believe,
quite fine, because similar limitations apply to optimization of
local-variable access; IOW, people who care about the speed of some
piece of code had better make that code part of some function body,
already:-).


Alex


More information about the Python-3000 mailing list