[issue44654] Refactor and clean up the union type implementation

Serhiy Storchaka report at bugs.python.org
Fri Jul 16 13:32:03 EDT 2021


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

> Yeah I noticed it re-lookups __module__ unnecessarily multiple times for the same type.

Actually I thought about this change, but did not implement it. Because it does not look performance critical, and future versions will likely do different tests (for example, testing the existence of special attribute, or check against lazily imported and cached classes from the typing module). Also, the test for TypeVar can be shared between genericaliasobject.c and unionobject.c.

It is mostly simple clean up, a line here, two lines there. genericaliasobject.c and unionobject.c could be merged in a single file, because they share several functions not used anywhere more. We perhaps merge them if more C implementations for typing be added in future.

----------

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


More information about the Python-bugs-list mailing list