On 2007-04-23, Steve Holden <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> So the question becomes: Why do Python dictionaries require
>> keys to be of an immutable type?
>
> Because otherwise people would expect to be able to use a list
> to select a dictionary entry even after they'd modified
> elements of the list after creating the dictionary entry. Which
> they couldn't. So Python doesn't let them use lists.

The interpreter explains it: "A list is not a hashable object."
Choosing a hash table instead of some kind of balanced tree seems
to be just an optimization. ;)

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to