Nested loops is strangely slow, totally at a loss.

Ian Kelly ian.g.kelly at gmail.com
Wed Dec 10 11:07:13 EST 2014


On Wed, Dec 10, 2014 at 9:01 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> This also seems perfectly natural:
>
> def len(iterable):
>     return sum(1 for item in iterable)
>
> My observation is that seems strange to me that one standard sequence
operation should be supported for arbitrary iterators and the other not.
>
> If the objection about `len(count())` is that the call would never
return, I'll point out that `-42 in count()` suffers the same problem.

To further clarify what I'm saying, I don't think that len(iterable) should
be supported. I'm just dismayed that "x in iterable" already is.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141210/57a287f3/attachment.html>


More information about the Python-list mailing list