[Python-Dev] ABC issues (original) (raw)

Armin Ronacher armin.ronacher at active-4.com
Tue May 27 21:16:28 CEST 2008


Hi,

Guido van Rossum <guido python.org> writes:

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. True. deque doesn't implement contains. However "in" still works because of the iter fallback. So from the API's perspective it's still compatible, even though it doesn't implement it. The same probably affects old style iterators (getitem with index). One could argue that they are still iterable or containers, but that's harder to check so probably not worth the effort.

>> 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. I would love to help on that as I'm very interested in that feature.

Regards, Armin



More information about the Python-Dev mailing list