[issue44642] Union of a type and the typing module function

Serhiy Storchaka report at bugs.python.org
Thu Jul 15 12:47:27 EDT 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

It is only reminder that our test for NewType is arbitrary. And it is not compatible with PR 9951. Possible solutions are:

1. Make NewType a class and add more strict test. Pro -- we can make arbitrary repr, contra -- it has small negative effect on performance. See issue34963.

2. Remove the test for NewType at all and allow or-ing types and arbitrary functions.

3. Introduce a special attribute to distinguish unionable objects. It will make the code of unionobject.c simpler.

I lean towards option 1 (not excluding 3). Small performance losses seem inevitable.

----------

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


More information about the Python-bugs-list mailing list