Skip to main content

itertools and builtins for AsyncIO and mixed iterables

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioitertools-0.7.1.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

aioitertools-0.7.1-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file aioitertools-0.7.1.tar.gz.

File metadata

  • Download URL: aioitertools-0.7.1.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for aioitertools-0.7.1.tar.gz
Algorithm Hash digest
SHA256 54a56c7cf3b5290d1cb5e8974353c9f52c677612b5d69a859369a020c53414a3
MD5 e254f9b156bd1dc11c0baed2af5c3161
BLAKE2b-256 dca0f149e54ea082e5f4ae71c68e8e72cab8749283329a7c2747336ef7b68dc0

See more details on using hashes here.

File details

Details for the file aioitertools-0.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aioitertools-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8972308474c41ed5e0636819f948ebff32f2318e70f7e7d23cd208c4357cc773
MD5 c7a1a15f9d80e786062ab458e11f3789
BLAKE2b-256 320b3260ac050de07bf6e91871944583bb8598091da19155c34f7ef02244709c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page