[Python-ideas] should `dict` supply a default `__missing__` implementation?

Neil Girdhar mistersheik at gmail.com
Tue Jul 5 15:18:00 EDT 2016


But neither UserDict nor MutableMapping defines __missing__ ?  What is a 
subclasser supposed to do?

On Wednesday, June 29, 2016 at 4:59:03 PM UTC-4, Guido van Rossum wrote:
>
> 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 <et... at stoneleaf.us 
> <javascript:>> 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... at python.org <javascript:> 
> > https://mail.python.org/mailman/listinfo/python-ideas 
> > Code of Conduct: http://python.org/psf/codeofconduct/ 
>
>
>
> -- 
> --Guido van Rossum (python.org/~guido) 
> _______________________________________________ 
> Python-ideas mailing list 
> Python... at python.org <javascript:> 
> https://mail.python.org/mailman/listinfo/python-ideas 
> Code of Conduct: http://python.org/psf/codeofconduct/ 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160705/7a4d23b9/attachment-0001.html>


More information about the Python-ideas mailing list