[Python-ideas] should `dict` supply a default `__missing__` implementation?
Guido van Rossum
guido at python.org
Wed Jun 29 16:57:58 EDT 2016
UserDict is superseded by MutableMapping.
I don't think we should make dict a kitchen sink class. I also don't
think we should particularly encourage subclassing it. So -1 on adding
dict.__missing__.
On Wed, Jun 29, 2016 at 12:30 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 06/29/2016 12:09 PM, Guido van Rossum wrote:
>
>> So providing the comprehensive base class is up to the user, not up to
>> the stdlib. Is that such a big deal?
>
>
> No, it's not. But it makes for a better user experience if the base class
> has the __missing__ method that raises a KeyError already.
>
> Didn't we add a UserDict that could be subclassed primarily because
> subclassing dict directly was such a poor user experience?
>
> If adding __missing__ to dict is huge (performance hit?), we don't do it.
> If it's not, I think we should. Maybe add it to UserDict if performance is
> a concern?
>
>
> --
> ~Ethan~
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
--
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas
mailing list