On 30/12/20 9:44 am, Christopher Barker wrote:
So there are dunders, and protocols, and ABCs, and they all overlap a bit in purpose. And "protocols" seem to be the least clearly specified.

> there are various protocols described in the C API docs, including
> the Mapping protocol:
>
> https://docs.python.org/3/c-api/mapping.html
> <https://docs.python.org/3/c-api/mapping.html>
>
> But I *think* that's really about the C API -- not what we are talking
> about here.

The library reference doesn't seem to use the terms "sequence protocol" and "mapping protocol". It talks about "sequence types" and "mapping
types", but doesn't use the word "protocol" in relation to them.

Nor is there any clear list of methods that a type needs to provide
in order to be considered a sequence or mapping. There are lists of
operations supported by the built-in container types, but those are
fairly extensive, and it's not obvious which ones are vital.

So are the "sequence protocol" and "mapping protocol" really mythical
beasts that don't really exist? Are they more akin to the infamous
"file-like object" which is whatever it needs to be for the purpose
at hand?

Guido has since said that the ABCs are intended to be definitive,
but the docs don't really make that clear either. (And the ABC doc page
talks about "APIs", not "protocols"!)

--
Greg
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/SU57ZIL3ESMT4QABP7I7HVG445EOALZP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to