Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44636>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to