[Python-Dev] Is explicit registration of Iterators needed? (original) (raw)

Guido van Rossum guido at python.org
Fri Oct 7 11:08:29 EDT 2016


On Fri, Oct 7, 2016 at 7:47 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:

On 07.10.16 17:37, Guido van Rossum wrote:

On Fri, Oct 7, 2016 at 6:36 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:

A number of builtin iterator classes (but not all builtin iterator classes) are registered with the Iterator ABC in Lib/collectionsabc.py. But isinstance(it, Iterable) check works without explicit registration, because Iterable has subclasshook that checks iterator methods. Is there a need in explicit registrations? Or their can be safely removed? The preferred apprach is actually inheritance; registration comes next; the subclasshook is a final compromise to the tradition of duck typing. I think the registrations should stay. Should we register missed builtin iterators? For example longrangeiterator.

I don't feel strongly about this either way. Let sleeping dogs lie, etc. (Is this related to issue 26906?)

-- --Guido van Rossum (python.org/~guido)



More information about the Python-Dev mailing list