On Sat, Dec 26, 2020 at 06:52:46PM -0800, Brendan Barnwell wrote:
On 2020-12-26 18:44, Steven D'Aprano wrote:
I think if we were designing mapping protocols now, that would be an excellent idea, but we aren't, we have decades of history from `dict` behind us. And protocols from dict use `keys()` and getitem. E.g. update.
What do you mean by "protocols from dict"? What are these protocols?
"And protocols from dict use `keys()` and getitem. E.g. update."
If I understand you right, that's not a protocol, that's just the behavior of the dict type specifically. As far as I can tell, it's not even documented behavior, so it doesn't constrain anything.
Yes it is documented:
and it was intentionally the inspiration for the behaviour of dict augmented assignment.
If you want to argue it's not a protocol, just an interface, okay, it's an interface. That's a difference that makes no difference.