Module src.qollib.collections.chunking

The chunking utility provides methods to break huge collections in chunks

@author: hoelken

Functions

def chunker(seq: list, size: int) ‑> list

Generates chunks (slices) from a given sequence

Params

  • seq: the list to chunk
  • size: the size of the chunks

Returns

A list of lists where each list has the length of the requested chunk size (maybe except the last one)

def indexed_chunks(seq: list, size: int) ‑> dict

Generates indexed chunks (slices) from a given sequence

Params

  • seq: List the list to chunk
  • size: Integer the size of the chunks

Returns

A dictionary with the index as key and the corresponding chunk as value. The length of the value arrays is the requested chunk size (maybe except the last one)