[Python-Dev] Issue 10194 - Adding a gc.remap() function

Hrvoje Niksic hrvoje.niksic at avl.com
Wed Oct 27 09:54:59 CEST 2010


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?


More information about the Python-Dev mailing list