[Python-Dev] ABC issues

Guido van Rossum guido at python.org
Tue May 27 19:26:46 CEST 2008


On Mon, May 26, 2008 at 11:59 AM, Raymond Hettinger <python at rcn.com> wrote:
>> * The 2.6-backported Mapping ABC has the 3.0 dict API,
>>  that is, it uses keys() that returns a view etc.
>
> Curious to hear what Guido thinks about this one.
> A nice use of the Mapping ABC is to be able to
> get 3.0 behaviors.  I thought that was the whole
> point of all these backports.  If the ABC gets altered,
> then it just makes the 2-to-3 conversion harder.

It's wrong if the ABC doesn't describe the behavior of actual
implementations; that is its primary purpose, the mixin class is a
nice side benefit.

We could make the incompatible mixin classes available separately
though, if you think they're useful.

>> * The 2.6 UserDict is not registered as a mapping.
>
> Since the API's are not currently the same, it makes
> sense that UserDict is not registered.
> If the Mapping ABC does get changed, only IterableUserDict
> should get registered.  A regular UserDict does not comply.

Fair enough. I recomment to fix the Mapping ABC and register IterableUserDict.

>> * collections.deque isn't registered as a MutableSequence.
>
> Deque's do not support count(), insert() or __iadd__().
> They should not be registered.  General purpose indexing
> into a deque is typically a mis-use of the data structure.
> It was provided only to make it easier to substitute for lists
> in apps the operate only one ends (i.e.d[0], d[1], d[-1], d[-2]
> but not d[i] to somewhere in the middle).

Hopefully they aren't registered in 3.0 either. :-)

>> If there are no objections, I will correct these issues
>> in the 2.6 and 3.0 branches.
>
> I think none of these changes should be made.

I'm in the middle. :-)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list