Skip to content

Instantly share code, notes, and snippets.

@wiccy46
Created March 26, 2020 10:18
Show Gist options
  • Save wiccy46/6c3ef75e60b0e2e1ecb01b8f6729b0b8 to your computer and use it in GitHub Desktop.
Save wiccy46/6c3ef75e60b0e2e1ecb01b8f6729b0b8 to your computer and use it in GitHub Desktop.
[batch] Batch generator #python
def batch_generator(items, batch_size):
batch = []
i = 0
for item in items:
batch.append(item)
if len(batch) == batch_size:
yield batch
batch = []
yield batch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment