Hashability questions

Dave Angel d at davea.name
Mon May 14 21:19:03 EDT 2012


On 05/14/2012 07:38 PM, Chris Kaynor wrote:
> On Sun, May 13, 2012 at 12:11 PM, Bob Grommes <bob.grommes at gmail.com> wrote:
>> <SNIP>
>>
>> The rule is that, if two objects return different results from
>> __hash__, they should never compare equal. The opposite rule also
>> holds true: if two objects compare equal, they should return the same
>> value from __hash__.
>>

You state those as if they were different rules.  Those are
contrapositives of each other, and therefore equivalent.

The inverse would be that two objects with the same __hash__ should
compare equal, and that's clearly not true.



-- 

DaveA




More information about the Python-list mailing list