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

Ilya Kulakov kulakov.ilya at gmail.com
Thu Nov 30 18:34:21 EST 2017


> Anyway, my expectation is that going along this way (i.e. removing all runtime API apart from a necessary minimum)
> will give a minor speed-up as compared to PEP 560 at the cost of a breaking change (even for small number of developers).

I don't think the change will be breaking: usage of this class will be entirely voluntarily and does not replace typing.Generic

> PEP 560 already gives overhead of 80% as compared to normal classes in worst case scenario
> (empty body with a single generic base). This is actually less than for ABCs (they can give up to 120% in worst case scenario).

GenericMeta inherits from ABCMeta. Do you mean that it will be removed after 560 lands?

> Moreover, performance is not a single motivation for PEP 560, there are other arguments such as metaclass conflicts which will
> not be solved without the machinery proposed by the PEP.

Perhaps you can consider designing Generic / GenericMeta in a way that will allow end user to create GenericStub-alike class without much trouble?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171130/ef51b694/attachment.html>


More information about the Python-ideas mailing list