➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients ncoghlan, rhettinger, serhiy.storchaka
Date 2017-10-18.16:43:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1508344981.58.0.213398074469.issue31815@psf.upfronthosting.co.za>
In-reply-to
Content
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
>>>
History
Date User Action Args
2017-10-18 16:43:01serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, ncoghlan
2017-10-18 16:43:01serhiy.storchakasetmessageid: <1508344981.58.0.213398074469.issue31815@psf.upfronthosting.co.za>
2017-10-18 16:43:01serhiy.storchakalinkissue31815 messages
2017-10-18 16:43:01serhiy.storchakacreate