[issue33939] Provide a robust O(1) mechanism to check for infinite iterators

Koos Zevenhoven report at bugs.python.org
Fri Aug 17 14:42:10 EDT 2018


Koos Zevenhoven <k7hoven at gmail.com> added the comment:

I'd say there are three different problems related to this:

(1) The inability of infinite iterators/iterables to say anything about their length

(2) The inability to interrupt C-level loops

(3) The horrible consequences of things like list(itertools.count()) that fill up the memory


The problems overlap only partially. Unfortunately, fixing any single one of these problems does not eliminate the two others. For example, (2) and (3) may happen just as well without the iterator protocol being involved. And (1) may just prevent you from checking if the iterable has enough elements for whatever you're doing.

----------
nosy: +koos.zevenhoven

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33939>
_______________________________________


More information about the Python-bugs-list mailing list