Skip to content

Instantly share code, notes, and snippets.

@anna-hope
Last active November 12, 2015 20:37
Show Gist options
  • Select an option

  • Save anna-hope/6b35f10555c786397876 to your computer and use it in GitHub Desktop.

Select an option

Save anna-hope/6b35f10555c786397876 to your computer and use it in GitHub Desktop.
make chunks from an iterable for parallel processing
def make_parallel_chunks(sequence, num_chunks, chunk_size):
for i in range(0, num_chunks, chunk_size):
yield itertools.islice(sequence, i, chunk_size + i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment