Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "yield from" in merge_sorted #550

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions toolz/itertoolz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand All @@ -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)

Expand All @@ -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):
Expand Down