collections_utils.py 277 B

12345678910
  1. from typing import Any, List
  2. def split(items: List[Any], chunk_size: int):
  3. """Splits provided list into chunks of given size"""
  4. assert chunk_size > 0, "Chunk size has to be > 0"
  5. for i in range(0, len(items), chunk_size):
  6. yield items[i : i + chunk_size]