Python hash() and equality behavior inconsistent with the Python documentation?

Viewed 46

I cannot reconcile this in my mind:

x = 'U2'
import numpy
y = numpy.array("ab").dtype

But then

>>> x == y
True
>>> help(hash)
Help on built-in function hash in module builtins:

hash(obj, /)
    Return the hash value for the given object.

    Two objects that compare equal must also have the same hash value, but the
    reverse is not necessarily true.

>>> hash(x) == hash(y)
False
>>>

How am I misinterpreting what I'm seeing?

Two objects that compare equal

>>> x == y
True

must also have the same hash value

>>> hash(x) == hash(y)
False

How am I forgetting how modus ponens works?

0 Answers
Related