chunk_iterable

lsst.utils.iteration.chunk_iterable(data: Iterable[Any], chunk_size: int = 1000) Iterator[Tuple[Any, ...]]

Return smaller chunks of an iterable.

Parameters:
dataiterable of anything

The iterable to be chunked. Can be a mapping, in which case the keys are returned in chunks.

chunk_sizeint, optional

The largest chunk to return. Can be smaller and depends on the number of elements in the iterator. Defaults to 1_000.

Yields:
chunktuple

The contents of a chunk of the iterator as a tuple. A tuple is preferred over an iterator since it is more convenient to tell it is empty and the caller knows it can be sized and indexed.