On Sat, Dec 26, 2020 at 4:35 PM Greg Ewing email@example.com 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.
-- Greg _______________________________________________ Python-ideas mailing list -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://firstname.lastname@example.org/message/Z4UL4N... Code of Conduct: http://python.org/psf/codeofconduct/