[New-bugs-announce] [issue31815] Make itertools iterators interrable
Serhiy Storchaka
report at bugs.python.org
Wed Oct 18 12:43:01 EDT 2017
New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:
Proposed PR makes tight C loops with itertools iterators interruptible with Ctrl-C. It adds checks for keyboard interrupt in iterators that can produce long sequences without advancing other iterators. For performance checks are performed only for every 0x1000-th item. If for generating new value other iterator should be advanced, the responsibility for checking for keyboard interrupt is attributed to that iterator.
This would solve the problem discussed on Python-ideas:
https://mail.python.org/pipermail/python-ideas/2017-October/047412.html
http://permalink.gmane.org/gmane.comp.python.ideas/47429
Example:
>>> import itertools
>>> it = itertools.count()
>>> it in it
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyboardInterrupt
>>>
----------
components: Extension Modules
messages: 304588
nosy: ncoghlan, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Make itertools iterators interrable
type: enhancement
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31815>
_______________________________________
More information about the New-bugs-announce
mailing list