Created
November 15, 2021 22:06
-
-
Save grenzi/1dacbf7fd60c423ce7542990f2e43e4f to your computer and use it in GitHub Desktop.
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
# just a simple way to process an iterable in chunks | |
def batch(iterable, n=1): | |
l = len(iterable) | |
for i in range(0, l, n): | |
yield iterable[i:min(i + n, l)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment