Registry / http-networking / aioitertools

aioitertools

JSON →
library0.13.0pypypi✓ verified 26d ago

aioitertools provides asynchronous versions of standard library `itertools` and `builtins` for AsyncIO and mixed iterables. It offers a unified interface for both standard and async iterators, wrapping standard iterables in async generators. The current version is 0.13.0, and it follows a feature release cadence.

pip install aioitertools
INSTALL
IMPORT
SIG · AIOITERTOOLS
A
aioitertools
http-networkingpythonv0.13.0
Install
1.7s avg
Import
220ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.13.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.240s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.200s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

iter
from aioitertools import iter
from aioitertools.builtins import iter
Aioitertools shadows standard library builtins directly at the top level for convenience.
map
from aioitertools import map
from aioitertools.builtins import map
Aioitertools shadows standard library builtins directly at the top level for convenience.
chain
from aioitertools import chain
from aioitertools.itertools import chain
Aioitertools shadows standard library itertools directly at the top level for convenience.
as_completed
from aioitertools.asyncio import as_completed
from aioitertools import as_completed
Asynchronous specific utilities are found under the `aioitertools.asyncio` submodule.

This quickstart demonstrates how to use `aioitertools.iter` to get an async iterator from both synchronous and asynchronous iterables, `aioitertools.next` to retrieve the next item, and `aioitertools.map` to apply an asynchronous function concurrently over an iterable.

import asyncio from aioitertools import iter, next, map async def async_generator(): for i in range(3): yield i await asyncio.sleep(0.01) async def process_item(item): # Simulate an async operation await asyncio.sleep(0.005) return item * 2 async def main(): # Using aioitertools.iter with a standard iterable it_sync = iter([1, 2, 3]) first_item = await next(it_sync) print(f"First item from sync: {first_item}") # Using aioitertools.iter with an async iterable it_async = iter(async_generator()) print("Items from async generator:") async for item in it_async: print(f" {item}") # Using aioitertools.map for concurrent async operations urls = ["url1", "url2", "url3"] async def fetch_url(url): # Replace with actual async HTTP request await asyncio.sleep(0.01) return f"Processed {url}" print("\nMapping async functions:") async for result in map(fetch_url, urls): print(f" {result}") if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
deprecatedThe `loop` parameter to `aioitertools.asyncio` functions was deprecated in v0.9.0 and completely removed in v0.11.0. This aligns with modern `asyncio` practices.
fix
Remove the `loop` argument when calling any `aioitertools.asyncio` functions. The event loop is now managed automatically.
affects: >=0.11.0
breakingSupport for Python 3.6 and 3.7 was dropped in version 0.12.0.
fix
Upgrade your Python environment to version 3.8 or newer.
affects: >=0.12.0
gotcha`aioitertools.asyncio.as_completed` yields actual results of awaitables, unlike the standard `asyncio.as_completed` which yields futures.
fix
Be aware that `aioitertools.asyncio.as_completed` directly gives you the resolved values, so you do not need to `await` on the yielded items.
affects: all
gotchaFunctions like `aioitertools.permutations` or `aioitertools.combinations` may consume the entire input iterable into memory before yielding any results. This can be inefficient for very large or infinite iterables.
fix
For very large iterables, consider if these functions are suitable, or use them with a limited subset of data. Be mindful of memory usage.
affects: all
gotchaSimilar to standard `itertools`, infinite iterators (e.g., `aioitertools.count`, `aioitertools.cycle`) will run indefinitely.
fix
Always combine infinite iterators with a 'stopping' function, such as `aioitertools.islice`, `aioitertools.takewhile`, or an explicit `break` condition in an `async for` loop, to prevent unbounded iteration.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aioitertools'
The 'aioitertools' package is not installed in the Python environment.
fix
Install the package using pip: 'pip install aioitertools'.
ImportError: cannot import name 'iter' from 'aioitertools'
The 'iter' function is not available in the 'aioitertools' module.
fix
Use the standard 'iter' function from Python's built-in library instead.
TypeError: 'async for' requires an object with an __aiter__ method, got 'list'
Attempting to use 'async for' on a standard list, which is not an asynchronous iterable.
fix
Convert the list to an asynchronous iterable using 'aioitertools.iter()' before iterating.
TypeError: 'async_generator' object is not callable
You are attempting to call an aioitertools asynchronous generator function as if it were a regular synchronous function, or trying to retrieve a single item from an async iterator without using 'await'.
fix
Ensure you use 'await' when retrieving single items from async iterators (e.g., `await ait.next(it)`) and ensure the function itself is awaited if it returns a single awaitable result. If it's an async generator, use 'async for' to iterate over it.
TypeError: 'async_generator' object is not iterable
You are trying to iterate over an asynchronous generator returned by an aioitertools function using a standard (synchronous) 'for' loop, instead of an 'async for' loop.
fix
Use 'async for' to iterate over the asynchronous generator within an 'async def' function. For example, `async for item in ait.map(func, data):`.
Upgrade
Version history
0.13.0latest on PyPI · released Nov 6, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
57 hits · last 30 days
node
46
OpenAI (training)
1
Resources