[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-31 Thread Terry J. Reedy
Terry J. Reedy added the comment: Dan, please leave this closed. It duplicates #31815 and should be closed on that grounds alone, regardless of the status of the latter. #31815 was closed in favor of #33939, which is open, with ongoing discussion. Resolution either way is blocked because

[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-27 Thread Jeffrey Kintscher
Change by Jeffrey Kintscher : -- nosy: +Jeffrey.Kintscher ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-25 Thread Dan Rose
Dan Rose added the comment: Oops you are right. These enter uninterruptible loops too. They are exceptional situations and should do the expected thing - throw exceptions as well. -- ___ Python tracker

[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Adding the __contains__() method to the count iterator would not solve the general problem with infinite iterators. For example with the following expressions: -1 in filter(None, itertools.count()) -1 in map(float, itertools.count()) It is not

[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-25 Thread Dan Rose
Dan Rose added the comment: The general problem with infinite iterators is indeed a bigger issue and its resolution would probably resolve this issue too. With the examples you gave at least the user can ctrl-c to interrupt. Entering an infinite, *uninterruptible* loop is a consequence so

[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-25 Thread SilentGhost
Change by SilentGhost : -- nosy: -SilentGhost ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-25 Thread Dan Rose
Dan Rose added the comment: Reopening. While my behavioral expectation may be wrong, the current behavior is inappropriate. It would make more sense for count to have a `__contains__` method which raises a TypeError. -- resolution: rejected -> status: closed -> open

[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-25 Thread Martin Panter
Martin Panter added the comment: Problems with long-running iterators are already discussed in: Issue 31815: rejected proposal to check for interrupts Issue 33939: proposal to flag iterators as being infinite -- nosy: +martin.panter ___ Python

[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-25 Thread SilentGhost
SilentGhost added the comment: This seem like a misdirected expectation. count returns a regular iterator and the purpose behind it is not to enable membership checks, this only works because it's a regular iterators and normal rules for checking membership are applied. In any case, it is

[issue37040] checking for membership in itertools.count enters infinite loop with no way to exit

2019-05-24 Thread Dan Rose
New submission from Dan Rose : Checking membership in `itertools.count()` will either return True in linear time or enter an infinite loop that cannot be terminated with Ctrl-c. This ``` import itertools 1 in itertools.count(0,2) ``` It is expected that the above code will use an efficient