itertools and builtins for AsyncIO and mixed iterables
Go to file
John Reese 4351371841 Version bump v0.6.1 2020-04-22 11:54:06 -07:00
.github Enable 3.8 builds 2019-11-12 19:03:01 -08:00
aioitertools Version bump v0.6.1 2020-04-22 11:54:06 -07: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 Version bump v0.6.0 2020-04-07 22:46:34 -07: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 Add changelog, contributers, and code of conduct to sdists 2019-11-12 21:01:10 -08:00
README.md Add more_itertools module with `take` and `chunked` 2020-03-26 23:11:41 +00:00
makefile Switch to flit and pyproject.toml 2020-04-22 11:54:06 -07:00
mypy.ini Switch to flit and pyproject.toml 2020-04-22 11:54:06 -07:00
pyproject.toml Switch to flit and pyproject.toml 2020-04-22 11:54:06 -07:00
requirements-dev.txt Update dev deps, add flit, drop wheel/twine 2020-04-22 11:54:06 -07: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, itertools.py, and [more_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.