itertools and builtins for AsyncIO and mixed iterables
Go to file
Zsolt Dollenstein bfc15b2ee6
Add more_itertools module with `take` and `chunked`
2020-03-26 23:11:41 +00:00
.github Enable 3.8 builds 2019-11-12 19:03:01 -08:00
aioitertools Add more_itertools module with `take` and `chunked` 2020-03-26 23:11:41 +00: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 Document wheel in changelog 2019-11-12 21:11:38 -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 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 Correct wheel command 2019-11-12 21:17:37 -08:00
requirements-dev.txt Include wheels in release process 2019-11-12 21:10:32 -08: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, 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.