When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?
horpner at yahoo.com
Wed Apr 25 16:55:23 CEST 2007
On 2007-04-25, Steve Holden <steve at holdenweb.com> wrote:
> Neil Cerutti wrote:
>> That would be documented as undefined behavior, and users
>> exhorted not to do such things.
>> Python's dictionaries are a proven winner--I'm definitely not an
>> advocate for changing them. But the general requirement for a
>> mapping container *isn't* that keys be immutable, but that you
>> either don't mutate keys, or don't do so without also reording
>> (rehashing?) the mapping.
> And which API do you use to "reord(er?) (rehash) the mapping"?
A pretty complex an unnecessary one, I'd guess. ;) Since you
would most likely need to remove the changed key from the
mapping, and then reinsert the new one, it's just as well to
leave the whole process entirely up to the user.
Which is how Python currently works. ;)
More information about the Python-list