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

Andrew Koenig ark-mlist at att.net
Tue Apr 20 11:33:48 EDT 2004


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




More information about the Python-Dev mailing list