This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients gvanrossum, kj, serhiy.storchaka
Date 2021-07-15.16:20:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626366001.1.0.145924348937.issue44636@roundup.psfhosted.org>
In-reply-to
Content
It is a difference with typing.Union which can cause confusion. If the union type is like a tuple and we leave a 1-type union, why do we bother with deduplication? Why int | str | int is collapsed into int | str?

Also it complicates the comparison implementation and produces surprising exceptions:

>>> int | str == {}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'

Also it breaks one of fundamental properties -- equal objects should have equal hashes.

>>> (int | int) == int
True
>>> hash(int | int) == hash(int)
False
History
Date User Action Args
2021-07-15 16:20:01serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, kj
2021-07-15 16:20:01serhiy.storchakasetmessageid: <1626366001.1.0.145924348937.issue44636@roundup.psfhosted.org>
2021-07-15 16:20:01serhiy.storchakalinkissue44636 messages
2021-07-15 16:20:01serhiy.storchakacreate