[Python-3000] Thoughts on collections.Container and collections.Iterable

Lisandro Dalcin dalcinl at gmail.com
Tue Feb 12 00:19:54 CET 2008


itertools.count() maybe ? Well not really infinite, it stops with
OverflowError...

But then (don't try this at home)...

>>> 4 in itertools.cycle(range(3)) # ups!

I seems that implicitely supporting containment testing for any
iterable is not always good idea.

On 2/9/08, Neil Toronto <ntoronto at cs.byu.edu> wrote:
> Neil Toronto wrote:
> > Guido van Rossum wrote:
> >> I would need to think more about this. I'm tempted not to do this, and
> >> let these ABCs denote the *explicit* presence of __contains__ and
> >> __iter__, respectively. Something that's iterable but doesn't
> >> implement __contains__ supports the 'in' operator very inefficiently
> >> (through linear search) which we might not want to encourage.
> > It could be worse. Is a container necessarily finite?
>
> I meant an iterable, of course, not a container.
>
> Neil
> _______________________________________________
> 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/dalcinl%40gmail.com
>


-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594


More information about the Python-3000 mailing list