Op 2005-01-11 said:
Given this hash function, how do you handle changed keys?
I don't change keys. The fact that I like to use a mutable
as a key doesn't imply I want to mutate a key.
And if you can't access the element when it's changed, what is the
advantage over using tuples?
The debate over what the adavantage is of tuples over lists or vice
versa as keys in dictionaries is IMO misguided. Whether I use a list
or a tuple is not guided by whether they are going to be used as a
key or not, but how in general the data is to be manipulated.
If the typical manipulations are modifications of an existing object,
I use a list, if the typical manipulation creates new objects out
of old ones I use a tuple. If I then find that I need this object
as a key, I just provide a hash so that I can use this object as
a key in a straight forward manner, without the hassle of converting
to and from a tuple all the time.