[New-bugs-announce] [issue44646] hash() of the unity type is not consistent with equality

Serhiy Storchaka report at bugs.python.org
Thu Jul 15 12:28:49 EDT 2021


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

There is a rule: equal hashable objects should have the same hash. The unity type violates it.

>>> x = int | str
>>> y = str | int
>>> x == y
True
>>> hash(x) == hash(y)
False

And hashes of equal unity type and typing.Union are different too.

>>> import typing
>>> z = typing.Union[int, str]
>>> x == z
True
>>> hash(x) == hash(z)
False

There is also a problem with a single type (see issue44636).

----------
components: Interpreter Core
messages: 397567
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: hash() of the unity type is not consistent with equality
type: behavior
versions: Python 3.10, Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44646>
_______________________________________


More information about the New-bugs-announce mailing list