itertools and builtins for AsyncIO and mixed iterables
Go to file
Amethyst Reese f9349de48e Build/publish both sdist and wheel 2024-09-01 20:36:46 -07:00
.github Build/publish both sdist and wheel 2024-09-01 20:36:46 -07:00
aioitertools Version bump v0.12.0 2024-09-01 20:27:31 -07:00
docs RTD base url 2024-07-22 12:43:34 -07:00
.flake8 Modernize metadata and deps, support 3.8-3.12 (#154) 2024-02-05 18:53:19 -08:00
.gitignore Update .gitignore (#176) 2024-08-31 23:31:53 -07:00
.mailmap mailmap 2023-12-27 13:39:04 -08:00
.readthedocs.yml Modernize metadata and deps, support 3.8-3.12 (#154) 2024-02-05 18:53:19 -08:00
CHANGELOG.md Version bump v0.12.0 2024-09-01 20:27:31 -07:00
CODE_OF_CONDUCT.md Update names and copyright 2022-08-23 21:54:36 -07:00
CONTRIBUTING.md Fix docstrings and markdown files so sphinx successfully compiles (#183) 2024-09-01 17:22:43 -07:00
LICENSE Update names and copyright 2022-08-23 21:54:36 -07:00
MANIFEST.in Add changelog, contributers, and code of conduct to sdists 2019-11-12 21:01:10 -08:00
README.md Fix docstrings and markdown files so sphinx successfully compiles (#183) 2024-09-01 17:22:43 -07:00
makefile Set up trusted publishing from GHA (#193) 2024-09-01 20:26:50 -07:00
pyproject.toml Set up trusted publishing from GHA (#193) 2024-09-01 20:26:50 -07:00

README.md

aioitertools

Implementation of itertools, builtins, and more for AsyncIO and mixed-type iterables.

documentation version changelog license

Install

aioitertools requires Python 3.8 or newer. You can install it from PyPI:

$ pip install aioitertools

Usage

aioitertools shadows the standard library whenever possible to provide asynchronous version of the modules and functions you already know. It's fully compatible with standard iterators and async iterators alike, giving you one unified, familiar interface for interacting with iterable objects:

from aioitertools import iter, next, map, zip

something = iter(...)
first_item = await next(something)

async for item in iter(something):
    ...


async def fetch(url):
    response = await aiohttp.request(...)
    return response.json

async for value in map(fetch, MANY_URLS):
    ...


async for a, b in zip(something, something_else):
    ...

aioitertools emulates the entire itertools module, offering the same function signatures, but as async generators. All functions support standard iterables and async iterables alike, and can take functions or coroutines:

from aioitertools import chain, islice

async def generator1(...):
    yield ...

async def generator2(...):
    yield ...

async for value in chain(generator1(), generator2()):
    ...

async for value in islice(generator1(), 2, None, 2):
    ...

See builtins.py, itertools.py, and more_itertools.py for full documentation of functions and abilities.

License

aioitertools is copyright Amethyst Reese, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.