[Python-3000] UserDict revamp

Raymond Hettinger python at rcn.com
Thu Feb 15 18:38:16 CET 2007

Since I contributed DictMixin and have been responsible for its maintenance,
if no one minds, I would like to be the one to migrate it to Py3.0.


----- Original Message ----- 
From: "Guido van Rossum" <guido at python.org>
To: "Steven Bethard" <steven.bethard at gmail.com>
Cc: "Python 3000" <python-3000 at python.org>; "Eduardo EdCrypt O. Padoan" 
<eopadoan at altavix.com>
Sent: Thursday, February 15, 2007 9:15 AM
Subject: Re: [Python-3000] UserDict revamp

> On 2/15/07, Steven Bethard <steven.bethard at gmail.com> wrote:
>> On 2/15/07, Guido van Rossum <guido at python.org> wrote:
>> > Perhaps the most egregious example is MixinDict, which currently
>> > assumes that keys() is a primitive operation returning a list, and
>> > builds __iter__() out of that. Obviously a better approach is to turn
>> > this around. (I'd have thought that ever since 2.2 this would have
>> > been the better design, but perhaps it was too late then already.)
>> I asked the same thing back in early 2005:
>>     http://mail.python.org/pipermail/python-list/2005-January/300042.html
>> Glad to hear I wasn't too out of my mind. ;-)
> Reading that post, I think that __len__ should also be part of the
> primitive operations, at least optionally. The dict view code to
> compare two views (or a view and a set; always excluding the values
> view which is not a set) for equality makes good use of this since it
> knows that if the lengths are unequal the objects cannot be equal. In
> order to determine equality without knowing the legth would double the
> cost of the operation because you'd end up having to iterate over each
> side, checking that all its elements are contained in the other side.
> With a length check, you only have to iterate over one side, and only
> if the lengths are equal.
> Another distinction I'd like to make is between mutable and immutable
> mappings. But maybe this is outside the realm of a *dict* mixin, and
> belongs in the (more speculative) discussion on abstract base classes.
> -- 
> --Guido van Rossum (home page: http://www.python.org/~guido/)
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-3000/python%40rcn.com 

More information about the Python-3000 mailing list