itertools and builtins for AsyncIO and mixed iterables
Go to file
Amethyst Reese 39c5fe810c
Modernize metadata and deps, support 3.8-3.12 (#154)
* Modernize metadata and deps, support 3.8-3.12

* rtd config

* rtd extras
2024-02-05 18:53:19 -08:00
.github Modernize metadata and deps, support 3.8-3.12 (#154) 2024-02-05 18:53:19 -08:00
aioitertools Modernize metadata and deps, support 3.8-3.12 (#154) 2024-02-05 18:53:19 -08:00
docs Make docs buildable without virtualenv, fix #113 2022-09-16 22:06:57 -07:00
.flake8 Modernize metadata and deps, support 3.8-3.12 (#154) 2024-02-05 18:53:19 -08:00
.gitignore Add sphinx documentation 2020-04-28 23:07:43 -07:00
.mailmap mailmap 2023-12-27 13:39:04 -08:00
.pylint Upgrade deps, fix lint 2020-11-08 13:43:28 -08:00
.readthedocs.yml Modernize metadata and deps, support 3.8-3.12 (#154) 2024-02-05 18:53:19 -08:00
CHANGELOG.md mailmap 2023-12-27 13:39:04 -08:00
CODE_OF_CONDUCT.md Update names and copyright 2022-08-23 21:54:36 -07:00
CONTRIBUTING.md Readme/contributing updates 2019-10-19 19:51:57 -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 Update url 2022-08-23 22:02:24 -07:00
makefile Modernize metadata and deps, support 3.8-3.12 (#154) 2024-02-05 18:53:19 -08:00
pyproject.toml Modernize metadata and deps, support 3.8-3.12 (#154) 2024-02-05 18:53:19 -08: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.6 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.