aleax at aleax.it
Tue Feb 4 10:51:45 CET 2003
Bengt Richter wrote:
> Numeric types used for keys obey the normal rules for numeric comparison:
> if two numbers compare equal (e.g., 1 and 1.0) then they can be used
> interchangeably to index the same dictionary entry.
> IWT this would create a slight performance hit looking for a match when
> the hash value is not there from a previous operation (i.e., do you
> potentially have to hash an integer, convert to float and hash that, and
No, there's a constraint on hash(): two objects that compare equal, a==b,
MUST ensure hash(a)==hash(b) if they're both usable as dict keys.
> This is compared to strings, that can't have equivalent values with
> different hashes AFAIK, unless maybe there is a unicode equivalency that
NO two objects can compare equal, be both usable as dict keys,
AND return different hashes.
More information about the Python-list