[Python-Dev] ABC issues
Guido van Rossum
guido at python.org
Tue May 27 19:33:26 CEST 2008
On Mon, May 26, 2008 at 4:11 PM, Raymond Hettinger <python at rcn.com> wrote:
>>> Deque's do not support count(), insert() or __iadd__().
>>> They should not be registered.
>
>> If it doesn't implement the MutableSequence protocol it still is a Sized
>> container. However currently it's not registered as a container.
>
> Seems useless to me. I don't think the intent of the ABC pep was
> to mandate that every class that defines __len__ must be registered
> as Sized.
There's no need to register as Sized -- the Sized ABC recognizes
classes that define __len__ automatically. The Container class does
the same looking for __contains__. Since the deque class doesn't
implement __contains__, it is not considered a Container -- correctly
IMO.
>> Another issue is that builtin types don't accept ABCs currently. For
>> example
>> set() | SomeSet() gives a TypeError, SomeSet() | set() however works.
>
> Pandora's Box -- sure you want to open it?
In 3.0 I'd like to; this was my original intent. In 2.6 I think it's
not worth the complexity, though I won't complain.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list