chia-blockchain/chia/util/chunks.py
Arvid Norberg 58019afd5b
chunk coin_store request into smaller sql queries (#10359)
* chunk coin_store request into smaller sql queries, to not exceed the limit of 999 on old versions of sqlite

* extend tests for chunks
2022-02-21 20:07:05 -08:00

10 lines
228 B
Python

from typing import Iterator, List, TypeVar
T = TypeVar("T")
def chunks(in_list: List[T], size: int) -> Iterator[List[T]]:
size = max(1, size)
for i in range(0, len(in_list), size):
yield in_list[i : i + size]