[issue39168] Generic type subscription is a huge toll on Python performance

Ivan Levkivskyi report at bugs.python.org
Tue Dec 31 14:56:41 EST 2019


Ivan Levkivskyi <levkivskyi at gmail.com> added the comment:

This issue came up few times before (although I can't find an issue here on b.p.o., maybe it was on typing-sig list). Although in micro-benchmarks the impact may seem big, in vast majority of applications it is rarely more that a percent or so.

On the other hand, IIRC the only reason `Generic.__new__()` exists is so that one can't write `Generic()` (i.e. instantiate a plain `Generic`). I would be totally fine if we just remove it in 3.9. Hopefully, people already learned what typing is for and don't need so much "protection" against not very meaningful things. Also, the error can be given by static type checkers, there is probably no need for a runtime error.

----------

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


More information about the Python-bugs-list mailing list