On 10/26/2010 07:11 PM, Peter Ingebretson wrote:
The main argument is that preserving immutable objects increases the
complexity of remapping and does not actually solve many problems.
The primary reason for objects to be immutable is so that their
comparison operators and hash value can remain consistent.

There are other reasons as well (thread-safety), but I guess those don't really apply to python. I guess one could defend the position that the tuple hasn't really "changed" if its elements merely get upgraded in this way, but it still feels wrong.

> Changing,
> for example, the contents of a tuple that a dictionary key references
> has the same effect as changing the identity of the tuple -- both
> modify the hash value of the key and thus invalidate the dictionary.
> The full reload processs needs to rehash collections invalidated by
> hash values changing, so we might as well modify the contents of
> tuples.

Do you also rehash when tuples of upgraded objects are used as dict keys?
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to