File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -753,15 +753,16 @@ which incur interpreter overhead.
753
753
def roundrobin(*iterables):
754
754
"roundrobin('ABC', 'D', 'EF') --> A D E B F C"
755
755
# Recipe credited to George Sakkis
756
- pending = len(iterables)
756
+ num_active = len(iterables)
757
757
nexts = cycle(iter(it).__next__ for it in iterables)
758
- while pending :
758
+ while num_active :
759
759
try:
760
760
for next in nexts:
761
761
yield next()
762
762
except StopIteration:
763
- pending -= 1
764
- nexts = cycle(islice(nexts, pending))
763
+ # Remove the iterator we just exhausted from the cycle.
764
+ num_active -= 1
765
+ nexts = cycle(islice(nexts, num_active))
765
766
766
767
def partition(pred, iterable):
767
768
'Use a predicate to partition entries into false entries and true entries'
You can’t perform that action at this time.
0 commit comments