[Python-ideas] Stub class for Generic to further improve PEP 560

Ivan Levkivskyi levkivskyi at gmail.com
Thu Nov 30 16:22:27 EST 2017


On 30 November 2017 at 22:08, Ilya Kulakov <kulakov.ilya at gmail.com> wrote:

> As explained in PEP 560, creation of Generic subclasses is much slower
> (~7x on my machine).
> My guess is that a limited number of applications actually need Generic
> classes at "production" runtime (i.e. when not under analysis of mypy or
> IDE).
>
> I propose a special class that will alias typing.Generic whenever
> typing.TYPE_CHECKING == True and a no-op stub otherwise.
>
>
FWIW, with PEP 560 generic classes will stay generic at runtime. I am not
sure what you mean by this, but
practically all existing runtime APIs (with few exceptions, see PEP 560)
for generics will stay.

--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171130/44261bb2/attachment.html>


More information about the Python-ideas mailing list