[Python-Dev] PEP 329: Treating Builtins as Constants
inthe Standard Library
Phillip J. Eby
pje at telecommunity.com
Tue Apr 20 12:01:04 EDT 2004
At 11:33 AM 4/20/04 -0400, Andrew Koenig wrote:
> > You could, of course, create a statement like "const len" to flag that
> > len will NOT be changed, thus creating true backwards compatibility,
>Somehow this idea is getting tangled in my mind with the distinction between
>mutable and immutable objects. When you use an object as a dict key, it
>must not change, in order to allow the optimization that keys can be sought
>through hashing rather than by sequential search. Similarly, making a name
>such as True immutable allows the optimization that "while True:" can be
>determined during compilation to be unconditional.
>I understand that there is a difference between the kinds of immutability,
>but still there seems to be a strong connection here.
I think it's a bad idea to confuse a read-only name binding, and the
concept of an immutable object. They aren't the same thing, although the
former can be implemented by a namespace that is the latter.
More information about the Python-Dev