3 ms·
Generally in Python it's much better to use list comprehensions when possible, it offers significant speedups usually: def zip(ls1, ls2): return [(ls1[
by jphoward 4y ago
Generally in Python it's much better to use list comprehensions when possible, it offers significant speedups usually:
def zip(ls1, ls2):
return [(ls1[i], ls2[i]) for i in range(min(len(ls1), len(ls2)))]
And indeed you could even use a generator instead:
def zip(ls1, ls2):
return ((ls1[i], ls2[i]) for i in range(min(len(ls1), len(ls2))))