Why are tuples immutable?
Scott David Daniels
Scott.Daniels at Acm.Org
Wed Dec 29 11:28:16 EST 2004
More information about the Python-list mailing list
Wed Dec 29 11:28:16 EST 2004
- Previous message (by thread): Why are tuples immutable?
- Next message (by thread): Why are tuples immutable?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Antoon Pardon wrote: > Op 2004-12-23, Scott David Daniels schreef <Scott.Daniels at Acm.Org>: >>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" I'd say this is a stretch. The "key" argument to sort is very new, and it is a function from data to a value. The "key" can be mutated only if the key function is picking out a mutable part of a data element. > 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. But Python has no "sorted list" data type, so it is perfectly reasonable to expect such lists to go through transitional representations. A set should not briefly have duplicate elements, a list should not vary in length when elements are replaced, an integer being continuously incremented should not be viewable from a separate thread as anything but monotonicly increasing; dictionaries are primitives and should not have observable transitional states. --Scott David Daniels Scott.Daniels at Acm.Org
- Previous message (by thread): Why are tuples immutable?
- Next message (by thread): Why are tuples immutable?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list