Why is dictionary.keys() a list and not a set?

"Martin v. Löwis" martin at v.loewis.de
Thu Nov 24 17:36:38 EST 2005


Mike Meyer wrote:
>>I trusted the doco which defines a set as "an unordered collection of
>>immutable values" (http://docs.python.org/lib/types-set.html).
> 
> 
> If the hash changes, you've screwed up the set. What it really should
> say is "collection of objects with fixed hashes", or words to that
> effect. Do you want to file a PR on this?

It's more than that: you really mean "hashable values", where "hashable"
does not just imply that the hash value is fixed, but also that the
equal objects hash same.

Regards,
Martin



More information about the Python-list mailing list