itertools and builtins for AsyncIO and mixed iterables
Project description
aioitertools
Implementation of itertools, builtins, and more for AsyncIO and mixed-type iterables.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aioitertools-0.6.1.tar.gz
.
File metadata
- Download URL: aioitertools-0.6.1.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27411653e28c391f2caa79476cc719591da88540278c53e7d6925d5b2fafa162 |
|
MD5 | e86f2b5459e30bba7492311723b5ec38 |
|
BLAKE2b-256 | 327f010fadd7b91d715ef0628f8a204aa6f8fd5b80ed02b5c808e5d4a797c6e9 |
File details
Details for the file aioitertools-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: aioitertools-0.6.1-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34155556df490ae1afb63b6393f80111cd3afdd32a5e6fe7c6fb897ace3277d3 |
|
MD5 | 9810414e3a7001585204e2d3eaada5ff |
|
BLAKE2b-256 | a690f8ce07b77a17f4140f55b066fee76a650ded3ed382293181fe492bd22c1d |