[Python-Dev] PEP 544: Protocols - second round

Guido van Rossum guido at python.org
Fri May 26 16:56:05 EDT 2017


On Thu, May 25, 2017 at 10:49 AM, Mark Shannon <mark at hotpy.org> wrote:

> I really like this PEP in general. I think this brings the type system for
> type-hints closer to Python semantics.
>

Thank you.


> But there are a few points I disagree with.
> I don't think Protocol types should be tied to ABCs. It just makes things
> more complex with no obvious benefit.
>

There are backwards compatibility benefits -- we could make e.g. Sequence a
Protocol in Python 3.7 and it would be possible to write code that inherits
from Sequence and works in Python 3.6 and 3.7. For this to work we need
some support for non-abstract methods in Protocols.


> I also think all references to 'isinstance' and 'issubclass' should be
> removed. Type-hints should not have runtime semantics, beyond those that
> they have as classes.


Again, backwards compatibility.


> In fact, there is no need for protocol types to be classes at all.
>

That's pretty much a separate discussion (see
https://github.com/python/typing/issues/432).

-- 
--Guido van Rossum (python.org/~guido <http://python.org/%7Eguido>)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170526/bf2b7930/attachment.html>


More information about the Python-Dev mailing list