Skip to main content

asyncio version of the standard multiprocessing module

Project description

aioitertools

itertools for AsyncIO and mixed iterables.

build status version license code style

Install

aioitertools requires Python 3.6 or newer. You can install it from PyPI:

$ pip3 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.

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.4.0.tar.gz (13.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: aioitertools-0.4.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for aioitertools-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e4d9d892290eccafb16c78e7a6d40e728541f6eb754a48fd74d76a6ccca6c428
MD5 3b7f452c6fe2d63b48cde63621649222
BLAKE2b-256 880fbb6e9b023f613b17404b59eabac7e2fe470c36607fcc1f341db0415814ae

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