Skip to content

Conversation

groutr
Copy link
Contributor

@groutr groutr commented Sep 14, 2022

Convert these loops:

for item in seq:
    yield item

To the more modern and slightly more efficient

yield from seq

A quick benchmark (a is a list of 30 sorted lists of 60 random integers)

# old
In [8]: %timeit list(merge_sorted(*a))
815 µs ± 31.3 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

# new
In [7]: %timeit list(merge_sorted(*a))
766 µs ± 26.2 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant