MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / zip_longest

Function zip_longest

scripts/routed_benchmark.py:75–97  ·  view source on GitHub ↗
(*iterables)

Source from the content-addressed store, hash-verified

73
74
75def zip_longest(*iterables):
76 # zip_longest('ABCD', 'xy', '123') → Ax1 By2 Cy3 Dy3
77
78 iterators = list(map(iter, iterables))
79 num_active = len(iterators)
80 if not num_active:
81 return
82
83 while True:
84 values = []
85 last_values = [None] * num_active
86 for i, iterator in enumerate(iterators):
87 try:
88 value = next(iterator)
89 except StopIteration:
90 num_active -= 1
91 if not num_active:
92 return
93 value = last_values[i]
94 iterators[i] = itertools.repeat(value)
95 values.append(value)
96 last_values = values
97 yield tuple(values)
98
99
100def run(args):

Callers 1

runFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected