[Python-Dev] Re: PEP 246 and Protocols (Was: Sneaky 'super' instances)

Phillip J. Eby pje@telecommunity.com
Fri, 13 Jun 2003 08:19:59 -0400


At 12:50 AM 6/13/03 -0400, Raymond Hettinger wrote:

>So, my questions is whether there is any reason not to adopt 246
>right away?  AFAICT, there is no competing proposal and nothing
>that would be harmed by adoption.  What's all the fuss about?

Guido has said (and I agree) that if Python includes adapt(), then the 
Python standard library should use it.  However, using it requires that the 
standard library have some standard way at least for it) of defining what a 
"protocol" is.  And that's where the holdup is, because Guido is not yet 
decided about what kind of interfaces or protocols Python should have, and 
he won't be until he's had enough experience with some of the 
approaches.  He's said he doesn't think Zope-style interfaces are going to 
be the way he wants to go, and that something more ABC-like (Abstract Base 
Class) would be preferable.

PyProtocols was my attempt to show that a PEP 246 mechanism can actually be 
pretty agnostic about what kind of interface objects are used, just like 
the '+' operator is agnostic about what object types it's used with.

However, as I've realized from this thread, PyProtocols still doesn't 
actually solve the real issue for Guido: even though PyProtocols doesn't 
care about what kind of interfaces are used, Guido *still* has to decide 
what kind the standard library should use, and I've only *added* another 
approach for him to evaluate!

Ah well.  :)  On the bright side, I think PyProtocols can alleviate *one* 
of his concerns, which was that having a Python-included interface type 
would make other interface types (e.g. Zope interfaces) "second-class 
citizens".  That is, I've demonstrated that it is possible to have a 
"protocol protocol", thus allowing different protocol or interface types to 
exist, even if they have no implementation in common (e.g. Twisted, Zope, 
and PyProtocols).

At this point, though, I don't see any reason to rush PEP 246 into the 
standard library, since there is now a packaged distribution that will 
presumably become a de facto standard for anybody who wants to use PEP 246, 
as it's the only PEP 246 implementation that you can use "out of the box" 
without having to write __conform__ or __adapt__ methods.

The only reason I even brought up the question here, was in relation to the 
adaptation-based documentation toolkit that I intend to write.