On Mon, 24 Feb 2020 at 12:10, Guido van Rossum <gu...@python.org> wrote:
>
> On Sat, Feb 22, 2020 at 4:45 PM Brandt Bucher <brandtbuc...@gmail.com> wrote:
>>
>> [quoting Nick]
>> > collections.Mapping and collections.MutableMapping could provide concrete 
>> > method implementations that make subclasses behave in a way that's similar 
>> > to built-in dicts
>>
>> Hm, haven't thought too much about this (I don't have much experience with 
>> the ABCs). Would they return dicts, or call the self.copy and self.update 
>> methods?
>>
>> Those are just hypothetical questions for now; I don't necessarily want to 
>> dig too far into that discussion again. But I agree that it's definitely 
>> worth considering. ;)
>
> Mapping and MutableMapping don't have copy() methods -- these are 
> intentionally narrower interfaces than dict. I think we should leave them 
> alone. The PEP does *not* propose to add `|` to Mapping, and that's 
> intentional. Because of this I think we should also not add `|=` to 
> MutableMapping, even though it does have an update() method. Adding it (even 
> with a default implementation) could cause discrepancies to virtual 
> subclasses registered with MutableMapping.register(C).

That's an excellent point regarding virtual subclasses - I was only
thinking about concrete subclasses. So if folks want to mimic the full
dict API, they can inherit from UserDict, while Mapping and
MutableMapping continue with their existing narrower APIs.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/E5V4RK4HCLZBKC2Z4HXXO4FZWWKGWZHX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to