New submission from Serhiy Storchaka <storchaka+cpyt...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue31815> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com