[Python-ideas] Membership of infinite iterators
Paul Moore
p.f.moore at gmail.com
Wed Oct 18 06:26:52 EDT 2017
On 18 October 2017 at 10:56, Koos Zevenhoven <k7hoven at gmail.com> wrote:
> I'm unable to reproduce the "uninterruptible with Ctrl-C" problem with
> infinite iterators. At least itertools doesn't seem to have it:
>
>>>> import itertools
>>>> for i in itertools.count():
> ... pass
> ...
> ^CTraceback (most recent call last):
> File "<stdin>", line 1, in <module>
> KeyboardInterrupt
That's not the issue here, as the CPython interpreter implements this
with multiple opcodes, and checks between opcodes for Ctrl-C. The
demonstration is:
>>> import itertools
>>> 'x' in itertools.count()
... only way to break out is to kill the process.
Paul
More information about the Python-ideas
mailing list