Op 2004-12-23, Scott David Daniels schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> Op 2004-12-22, Jeff Shannon schreef <[EMAIL PROTECTED]>: >>>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.
But similar problems can happen in a sorted list, where the sort is done on a "key" of the data and where you don't want duplicate "keys". If you then mutate a "key", it may be possible to insert a duplicate "key" in the sorted list because the list isn't sorted anymore. If you then resort your list you also have to determine how to merge the two items with the same "key" This just to show that repairing sorted lists can be just as troublesome as repairing dictionaries. People who think sorted lists of mutable objects is less bothersome as dictionaries with mutable keys, haven't thought things through IMO. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list