aioplus.abatched¶
- aioplus.abatched(aiterable, /, *, n, strict=False)¶
Iterate
aiterableby batches of lengthn.- Parameters:
- Returns:
Iterator.
- Return type:
AsyncIterator[tuple[T, …]]
Notes
If
strictisTrueand the total number of objects is not divisible byn, then raisesValueError. IfFalse, the last batch may be shorter thann.
Examples
>>> aiterable = arange(23) >>> [batch async for batch in abatched(aiterable, n=3)] [(0, 1, 2), (3, 4, 5), ..., (18, 19, 20), (21, 22)]
See also