Why are tuples immutable?

Scott David Daniels Scott.Daniels at Acm.Org
Thu Dec 23 16:22:07 CET 2004


Antoon Pardon wrote:
> Op 2004-12-22, Jeff Shannon schreef <jeff at ccvcorp.com>:
>>The problem is that once the object has mutated, you *don't know* what 
>>bucket it used to sort into.  There is no point at which a dictionary 
>>can see "before" and "after" -- it just sees two different lists.

This is half the problem.  In the period where an element is in the
wrong hash bucket, a new entry for the same value can be created in
the proper hash bucket.  Then the code will have to determine how to
merge two entries at rehash time.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list