Message348395
Reproducible with current master (3.9, 151b91dfd21a100ecb1eba9e293c0a8695bf3bf5)
I would expect itertools.combinations to be lazy in the sense that it should not exhaust the input iterator in constructor time.
import itertools;
itertools.combinations(itertools.count(),2)
should return instantly. Instead it "hangs" until the process is killed.
Similarly, one can reproduce with the following simple crafted generator:
Python 3.9.0a0 (heads/master-dirty:151b91d, Jul 24 2019, 19:51:53)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def mygenerator_with_exception():
yield 2
yield 2
yield 3
raise Exception("Should not be raised")
... ... ... ... ...
>>> g = mygenerator_with_exception()
>>> import itertools
>>> itertools.combinations(g,2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in mygenerator_with_exception
Exception: Should not be raised
Could you please consider making itertools.combinations truely lazy? |
|
Date |
User |
Action |
Args |
2019-07-24 18:18:17 | furiel | set | recipients:
+ furiel |
2019-07-24 18:18:17 | furiel | set | messageid: <1563992297.11.0.886326187816.issue37671@roundup.psfhosted.org> |
2019-07-24 18:18:17 | furiel | link | issue37671 messages |
2019-07-24 18:18:16 | furiel | create | |
|