项目作者: omnilib

项目描述 :
itertools and builtins for AsyncIO and mixed iterables
高级语言: Python
项目地址: git://github.com/omnilib/aioitertools.git
创建时间: 2018-06-26T16:49:46Z
项目社区:https://github.com/omnilib/aioitertools

开源协议:MIT License

下载


aioitertools

Implementation of itertools, builtins, and more for AsyncIO and mixed-type iterables.

documentation
version
changelog
license

Install

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

  1. $ 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:

  1. from aioitertools import iter, next, map, zip
  2. something = iter(...)
  3. first_item = await next(something)
  4. async for item in iter(something):
  5. ...
  6. async def fetch(url):
  7. response = await aiohttp.request(...)
  8. return response.json
  9. async for value in map(fetch, MANY_URLS):
  10. ...
  11. async for a, b in zip(something, something_else):
  12. ...

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:

  1. from aioitertools import chain, islice
  2. async def generator1(...):
  3. yield ...
  4. async def generator2(...):
  5. yield ...
  6. async for value in chain(generator1(), generator2()):
  7. ...
  8. async for value in islice(generator1(), 2, None, 2):
  9. ...

See builtins.py, itertools.py, and more_itertools.py for full
documentation of functions and abilities.

License

aioitertools is copyright Amethyst 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.