itertools and builtins for AsyncIO and mixed iterables
Go to file
John Reese e5b1b890c1 Version bump v0.5.0 2019-11-12 20:55:13 -08:00
.github Enable 3.8 builds 2019-11-12 19:03:01 -08:00
aioitertools Version bump v0.5.0 2019-11-12 20:55:13 -08:00
.gitignore Ignore vscode 2019-04-29 22:08:21 -07:00
.pylint Replace type ignore in as_completed with cast and comment 2019-10-26 18:52:19 -07:00
CHANGELOG.md Add a changelog 2019-11-12 20:55:03 -08:00
CODE_OF_CONDUCT.md Implement builtins 2018-06-26 20:54:16 -07:00
CONTRIBUTING.md Readme/contributing updates 2019-10-19 19:51:57 -07:00
LICENSE Initial commit 2018-06-26 09:49:46 -07:00
MANIFEST.in Implement builtins 2018-06-26 20:54:16 -07:00
README.md Readme/contributing updates 2019-10-19 19:51:57 -07:00
makefile Add isort, reference every via `python -m`, etc 2019-10-19 17:27:20 -07:00
requirements-dev.txt Dev requirements 2019-10-19 17:26:17 -07:00
setup.cfg Tox config 2019-11-12 19:02:18 -08:00
setup.py Platform independent encoding on setup.py 2019-10-31 10:56:54 +03:00

README.md

aioitertools

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

build status code coverage version license code style

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 and itertools.py for full documentation of functions and abilities.

License

aioitertools is copyright John 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.