This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author david.lindquist
Recipients david.lindquist, docs@python
Date 2014-02-22.06:36:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The roundrobin example in the Recipes section of the itertools documentation ( is overly complex. Here is a more straightforward implementation:

def roundrobin(*iterables):
    "roundrobin('ABC', 'D', 'EF') --> A D E B F C"
    sentinel = object()
    it = chain.from_iterable(zip_longest(fillvalue=sentinel, *iterables))
    return (i for i in it if i is not sentinel)

Not only is it one-third the lines of the existing example, benchmarks show it to be more than twice as fast.

See attached patch file.
Date User Action Args
2014-02-22 06:36:58david.lindquistsetrecipients: + david.lindquist, docs@python
2014-02-22 06:36:58david.lindquistsetmessageid: <>
2014-02-22 06:36:57david.lindquistlinkissue20727 messages
2014-02-22 06:36:56david.lindquistcreate