Skip to content

Instantly share code, notes, and snippets.

@dvdotsenko
dvdotsenko / aio_map.py
Last active June 19, 2025 20:52
python asyncio map() and filter() Like Gevent imap_unordered Can chain / wrap one into another.
import asyncio
from collections import deque
from typing import Any, Callable, Collection, AsyncIterator, Iterator, Union
async def _next(gg):
# repackaging non-asyncio next() as async-like anext()
try:
return next(gg)
except StopIteration: