This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ Iterate over multiple iterables in batches. | |
| Inspired by 'equivalent' definition of zip in docs here: | |
| https://docs.python.org/3.4/library/functions.html#zip | |
| """ | |
| def group_zip(*iterables, batchsize=2): | |
| # N.B. this truncates to shortest iterable | |
| sentinel = object() | |
| iterators = [iter(it) for it in iterables] |