On Sun, Oct 27, 2019 at 6:26 PM Steve White <stevan.wh...@gmail.com> wrote:
> As near as I can tell, returning the id() in __hash__() results in a
> perfect hash key.  I really want to know if that is true.
> Because if it is true, any further layer is simply covering for a
> failing in the documentation.

Only if your __eq__() does not return True for anything other than
itself. That is the entire definition of __hash__ - it needs to return
the same value for two objects that are equal. This is exactly what
the documentation said, as multiple people have posted here.

If your object is equal only to itself, then its hash can be its
identity. Otherwise it should not. It is that simple.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to