From 50c94ad33b65d86d8f07be3923088833c7723ec3 Mon Sep 17 00:00:00 2001 From: Ryan Grout Date: Wed, 14 Sep 2022 10:23:30 -0500 Subject: [PATCH] Use yield from. --- toolz/itertoolz.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/toolz/itertoolz.py b/toolz/itertoolz.py index 89931ae5..05803b80 100644 --- a/toolz/itertoolz.py +++ b/toolz/itertoolz.py @@ -148,8 +148,7 @@ def _merge_sorted_binary(seqs): try: val2 = next(seq2) except StopIteration: - for val1 in seq1: - yield val1 + yield from seq1 return for val1 in seq1: @@ -167,12 +166,10 @@ def _merge_sorted_binary(seqs): yield val1 else: yield val2 - for val2 in seq2: - yield val2 + yield from seq2 return yield val1 - for val1 in seq1: - yield val1 + yield from seq1 def _merge_sorted_binary_key(seqs, key): @@ -191,8 +188,7 @@ def _merge_sorted_binary_key(seqs, key): try: val2 = next(seq2) except StopIteration: - for val1 in seq1: - yield val1 + yield from seq1 return key2 = key(val2) @@ -213,12 +209,10 @@ def _merge_sorted_binary_key(seqs, key): yield val1 else: yield val2 - for val2 in seq2: - yield val2 + yield from seq2 return yield val1 - for val1 in seq1: - yield val1 + yield from seq1 def interleave(seqs):