Improve parallel map API
This commit is contained in:
parent
5dc85905b4
commit
154cc52fa6
6 changed files with 94 additions and 84 deletions
|
|
@ -3,13 +3,13 @@ from typing import Iterable, List, TypeVar
|
|||
T = TypeVar("T")
|
||||
|
||||
|
||||
def chunk(values: Iterable[T], chunk_length: int) -> Iterable[T]:
|
||||
assert chunk_length >= 1
|
||||
def chunk(values: Iterable[T], chunk_size: int) -> Iterable[T]:
|
||||
assert chunk_size >= 1
|
||||
|
||||
result: List[T] = []
|
||||
for v in values:
|
||||
result.append(v)
|
||||
if len(result) == chunk_length:
|
||||
if len(result) == chunk_size:
|
||||
yield result
|
||||
result = []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue