Skip to content

Commit

Permalink
Performance notes for interleave_longest and roundrobin
Browse files Browse the repository at this point in the history
  • Loading branch information
bbayles committed Jan 10, 2018
1 parent 9fc800a commit 821450b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions more_itertools/more.py
Expand Up @@ -801,6 +801,10 @@ def interleave_longest(*iterables):
>>> list(interleave_longest([1, 2, 3], [4, 5], [6, 7, 8]))
[1, 4, 6, 2, 5, 7, 3, 8]
This function produces the same output as :func:`roundrobin`, but may
perform better for some inputs (in particular when the number of iterables
is large).
"""
i = chain.from_iterable(zip_longest(*iterables, fillvalue=_marker))
return (x for x in i if x is not _marker)
Expand Down
4 changes: 3 additions & 1 deletion more_itertools/recipes.py
Expand Up @@ -300,7 +300,9 @@ def roundrobin(*iterables):
>>> list(roundrobin('ABC', 'D', 'EF'))
['A', 'D', 'E', 'B', 'F', 'C']
See :func:`interleave_longest` for a slightly faster implementation.
This function produces the same output as :func:`interleave_longest`, but
may perform better for some inputs (in particular when the number of
iterables is small).
"""
# Recipe credited to George Sakkis
Expand Down

0 comments on commit 821450b

Please sign in to comment.