aioitertools

Implementation of itertools, builtins, and more for asyncio and mixed iterables.

Library
PyPI
v0.13.0
278stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
36/100Needs Attention
Development Activity4
Maintenance0
Community60
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture78
Code Quality82
Innovation74
Learning Curve80

aioitertools is a Python library that provides asynchronous versions of the standard library’s itertools module and iteration builtins. It shadows familiar functions like iter, next, map, zip, chain, and islice so you can work with async iterables using the same interface you already know.

Every function accepts both standard iterables and async iterables interchangeably, and callbacks can be plain functions or coroutines. This lets you compose async pipelines - fetching URLs, streaming records, batching results - without hand-writing async for boilerplate or juggling two separate iteration APIs.

What You Get

  • Async builtins: iter, next, map, zip, and enumerate that await transparently
  • The full itertools module emulated as async generators with identical signatures
  • A port of more_itertools helpers for advanced async iteration patterns
  • Uniform handling of standard iterables and async iterables in the same call
  • Complete type annotations and a py.typed marker for static type checking

Common Use Cases

  • Mapping an async fetch coroutine over many URLs and consuming results as they arrive
  • Chaining or zipping multiple async generators into a single stream
  • Slicing or batching async streams with islice, chunked, and friends
  • Migrating synchronous itertools-based pipelines to asyncio with minimal rewrites

Under The Hood

Architecture - The package is organized by the standard-library surface it mirrors: builtins.py reimplements iter/next/map/zip/enumerate, itertools.py reimplements the itertools functions as async generators, and more_itertools.py ports the popular third-party helpers. A shared helpers.py/types.py layer normalizes any input into an async iterator via a common iter() shim, which is what lets every function accept sync and async iterables interchangeably. asyncio.py adds convenience wrappers for gathering results.

Tech Stack - Pure Python targeting 3.9+, with zero runtime dependencies. It ships a py.typed marker and full annotations, builds with modern pyproject.toml/setuptools tooling, and publishes documentation via Sphinx to readthedocs.

Code Quality - The library carries a dedicated tests package, is fully type-annotated, and follows a consistent module-per-stdlib-surface structure that keeps each function small and focused. Naming deliberately matches the standard library so behavior is predictable and easy to audit against CPython’s reference semantics.

API Design - Ergonomics are the whole point: by shadowing standard names (from aioitertools import iter, next, map, zip), existing itertools knowledge transfers directly and pipelines read almost identically to their synchronous counterparts. Accepting both function and coroutine callbacks, and both iterable kinds, removes the usual async/sync branching boilerplate.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search