The unPEP: List-Tuple Unification

Raymond Hettinger othello at javanet.com
Fri Jul 20 15:31:44 EDT 2001


Steve Holden wrote:

> "I don't
> see why immutability has to be a one-way attribute when converiosn between
> list and tuple is so easy.
>
> regards
>  Steve

Dictionary's rely on immutability of keys.  If the list is used as a key, then
it cannot be subsequently assigned to without breaking the key reference.

Also, immutability can be an important internal optimization. Once made
immutable, the list can be fixed length, stored as an array, and hashed
once and for all.

tuples-who-needs-them-ly, yours Raymond




More information about the Python-list mailing list