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 serhiy.storchaka
Recipients Dubslow, docs@python, rhettinger, serhiy.storchaka, terry.reedy, tim.peters
Date 2017-11-21.17:28:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511285336.42.0.213398074469.issue32099@psf.upfronthosting.co.za>
In-reply-to
Content
Today I have published a similar recipe on Python-Ideas. It uses popleft/append instead of __getitem__/rotate.

def roundrobin(*iterables):
    "roundrobin('ABC', 'D', 'EF') --> A D E B F C"
    nexts = deque(iter(it).__next__ for it in iterables)
    popleft = nexts.popleft
    append = nexts.append
    while nexts:
        next = popleft()
        try:
            yield next()
        except StopIteration:
            pass
        else:
            append(next)

It is faster (10-25%) in all microbenchmarks that I did (Steven's benchmarks for small number of iterables and my examples for large number of iterables).
History
Date User Action Args
2017-11-21 17:28:56serhiy.storchakasetrecipients: + serhiy.storchaka, tim.peters, rhettinger, terry.reedy, docs@python, Dubslow
2017-11-21 17:28:56serhiy.storchakasetmessageid: <1511285336.42.0.213398074469.issue32099@psf.upfronthosting.co.za>
2017-11-21 17:28:56serhiy.storchakalinkissue32099 messages
2017-11-21 17:28:56serhiy.storchakacreate