Message306670
While we're on the topic, I had some thought of also adding a similar recipe to https://docs.python.org/3/library/collections.html#deque-recipes . The alternative recipe is slower is common cases but doesn't degrade when there are a huge number of iterables:
def roundrobin(*iterables):
"roundrobin('ABC', 'D', 'EF') --> A D E B F C"
nexts = deque(iter(it).__next__ for it in iterables)
while nexts:
try:
while True:
yield nexts[0]()
nexts.rotate(-1)
except StopIteration:
nexts.popleft() |
|
Date |
User |
Action |
Args |
2017-11-21 17:04:18 | rhettinger | set | recipients:
+ rhettinger, tim.peters, terry.reedy, docs@python, serhiy.storchaka, Dubslow |
2017-11-21 17:04:18 | rhettinger | set | messageid: <1511283858.52.0.213398074469.issue32099@psf.upfronthosting.co.za> |
2017-11-21 17:04:18 | rhettinger | link | issue32099 messages |
2017-11-21 17:04:18 | rhettinger | create | |
|