[Python-Dev] PEP 329: Treating Builtins as Constants in the Standard Library

Phillip J. Eby pje at telecommunity.com
Mon Apr 19 09:30:55 EDT 2004

At 08:54 AM 4/19/04 -0400, Raymond Hettinger wrote:
>Comments are invited on a new pep:
>         http://www.python.org/peps/pep-0329.html

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.)

More information about the Python-Dev mailing list