def test_from_to_iterable_pipe(nums): nums_py = nums nums_pl = (nums | aio.from_iterable() | list) assert nums_pl == nums_py
def test_from_to_iterable(nums): nums_py = nums nums_pl = aio.from_iterable(nums) nums_pl = list(nums_pl) assert nums_pl == nums_py
def test_from_to_iterable(nums): nums_pl = nums nums_pl = aio.from_iterable(nums_pl) nums_pl = cz.partition_all(10, nums_pl) nums_pl = aio.map(sum, nums_pl) nums_pl = list(nums_pl) nums_py = nums nums_py = cz.partition_all(10, nums_py) nums_py = map(sum, nums_py) nums_py = list(nums_py) assert nums_py == nums_pl
from pypeln import asyncio_task as aio list_acc = [] def batch(x, n): if len(list_acc) == n: list_out = list(list_acc) list_acc.clear() yield list_out else: list_acc.append(x) print( range(100) | aio.from_iterable() | aio.flat_map(lambda x: batch(x, 10)) | aio.map(sum) | list)