At 08:54 AM 4/19/04 -0400, Raymond Hettinger wrote:
Comments are invited on a new pep:
I'm not sure I understand the reasoning for implementing this via a bytecode hack, rather than in the compiler or loading mechanisms. I think I'd rather see something like:
from __future__ import fast_globals
which would mean that globals and builtins could be considered constants unless declared with 'global' at the module level. Then, the compiler could optimize any undeclared builtins, and the 'MAKE_FUNCTION' opcode could bind any constants defined as of the function's declaration.
Finally, the module object thus created would ban any __setattr__ on any constant that has been bound into a function. (Since these are the only setattrs that could cause harm.)