On Sat, Dec 26, 2020 at 4:35 PM Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
On 27/12/20 10:15 am, Christopher Barker wrote:
> ... the only thing
> you should *need* is an items() method that returns an iterable (pf
> pairs of objects).

It seems to me it would be more fundamental to use iteration to get
the keys and indexing to get the corresponding values. You're only
relying on dunder methods then.

And that seems to work as well, I made a "Mapping" with a do-nothing .items(), but a functional __iter__ and __getitem__

and that seems to work as well.

Though it seems that .items() could be more efficient, if it's there. Maybe not significant, but still ...

In any case, I'd like to see the protocol be duck-typed, like, as far as I know, every other protocol in Python, rather than doing actual type checking.

I'd live to hear why it currently checks for Mapping, rather than simply calling the methods it needs.


Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/Z4UL4NZQ7JS3JLVMYOZZVN2N3FL6UKCW/
Code of Conduct: http://python.org/psf/codeofconduct/

Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython