Message397564
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 |
|
Date |
User |
Action |
Args |
2021-07-15 16:20:01 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, kj |
2021-07-15 16:20:01 | serhiy.storchaka | set | messageid: <1626366001.1.0.145924348937.issue44636@roundup.psfhosted.org> |
2021-07-15 16:20:01 | serhiy.storchaka | link | issue44636 messages |
2021-07-15 16:20:01 | serhiy.storchaka | create | |
|