from collections import AsyncIterable from typing import Callable, AsyncGenerator async def async_filter(fun: Callable, iterable: AsyncIterable) -> AsyncGenerator: async for val in iterable: if fun(val): yield val