<div dir="ltr"><div class="gmail_default" style=""><font face="arial, helvetica, sans-serif">On Wed, Oct 18, 2017 at 2:08 PM, Nick Coghlan <span dir="ltr" style=""><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br></font></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><font face="arial, helvetica, sans-serif">On 18 October 2017 at 20:39, Koos Zevenhoven <span dir="ltr"><<a href="mailto:k7hoven@gmail.com" target="_blank">k7hoven@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><span class="m_-2999293347182333719gmail-"><div dir="auto" style="">On Oct 18, 2017 13:29, "Nick Coghlan" <<a href="mailto:ncoghlan@gmail.com" target="_blank" style="">ncoghlan@gmail.com</a>> wrote:<br></div></span><span class="m_-2999293347182333719gmail-"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_-2999293347182333719gmail-m_-2423510541164657263quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="m_-2999293347182333719gmail-m_-2423510541164657263quoted-text">On 18 October 2017 at 19:56, Koos Zevenhoven <span dir="ltr"><<a href="mailto:k7hoven@gmail.com" target="_blank">k7hoven@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span class="m_-2999293347182333719gmail-m_-2423510541164657263m_183500653703616643gmail-"></span><div class="gmail_extra"><div class="gmail_quote"><span class="m_-2999293347182333719gmail-m_-2423510541164657263m_183500653703616643gmail-"></span><div style="">I'm unable to reproduce the "uninterruptible with Ctrl-C" problem with infinite iterators. At least itertools doesn't seem to have it:</div><div style=""><br></div><div style=""><div>>>> import itertools</div><div>>>> for i in itertools.count():</div><div>... pass</div><div>... </div></div></div></div></div></blockquote><div><br></div></div><div>That's interrupting the for loop, not the iterator. This is the test case you want for the problem Jason raised:</div><div><br></div><div> >>> "a" in itertools.count()</div><div><br></div><div>Be prepared to suspend and terminate the affected process, because Ctrl-C isn't going to help :)<br></div></div></div></div></blockquote></div></div></span></div><div dir="auto"><br></div><div dir="auto"><span class="m_-2999293347182333719gmail-"><div dir="auto" style="font-size:13.696px">I'm writing from my phone now, cause I was dumb enough to try list(count())</div></span></div></div></blockquote><div><br></div></font></span><div><font face="arial, helvetica, sans-serif">Yeah, that's pretty much the worst case example, since the machine starts thrashing memory long before it actually gives up and starts denying the allocation requests :(<br></font></div><span class=""><font face="arial, helvetica, sans-serif"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto"><span class="m_-2999293347182333719gmail-"><div dir="auto" style="font-size:13.696px">But should it be fixed in list or in count?</div></span></div></div></blockquote><div><br></div></font></span><div><font face="arial, helvetica, sans-serif">That one can only be fixed in count() - list already checks operator.length_hint(), so implementing itertools.count.__length_hint_<wbr>_() to always raise an exception would be enough to handle the container constructor case.<br></font></div></div><div class="gmail_quote"><font face="arial, helvetica, sans-serif"><br></font></div></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-family:monospace,monospace">While that may be a convenient hack to solve some of the cases, maybe it's possible for list(..) etc. to give Ctrl-C a chance every now and then? (Without a noticeable performance penalty, that is.) That would also help with *finite* C-implemented iterables that are just slow to turn into a list. </div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">If I'm not mistaken, we're talking about C-implemented functions that iterate over C-implemented iterators. It's not at all obvious to me that it's the iterator that should handle Ctrl-C.</div></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">––Koos</div></div><font face="arial, helvetica, sans-serif"><br clear="all"></font><div><font face="arial, helvetica, sans-serif"><br></font></div><font face="arial, helvetica, sans-serif">-- <br></font><div class="gmail_signature" data-smartmail="gmail_signature"><font face="arial, helvetica, sans-serif">+ Koos Zevenhoven + <a href="http://twitter.com/k7hoven" target="_blank">http://twitter.com/k7hoven</a> +</font></div>
</div></div>