Toggle Menu
Prev Up Next

# `langchain_core.utils.iter`.batch_iterate

langchain_core.utils.iter.batch_iterate(size: Optional[int], iterable: Iterable[T]) → Iterator[List[T]]

  Utility batching function.

  Parameters

    - size (Optional[int]) – The size of the batch. If None, returns a single batch.

    - iterable (Iterable[T]) – The iterable to batch.

  Returns

    An iterator over the batches.

  Return type

    Iterator[List[T]]