builtins,itertoolsandmore-itertools- but asynchronous;- Seamless sync-async bridging (
awaitify,anextify, etc.); - Early returns never cause unawaited coroutine warnings.
The library is available as aioplus on PyPI:
pip install aioplusFor more, see the documentation.
>>> executor = CallerThreadExecutor()
>>> loop = asyncio.new_event_loop()
>>> loop.set_default_executor(executor)For more, see the documentation.
>>> aiterable = arange(23)
>>> await aall(aiterable)
FalseFor more, see the documentation.
>>> aiterable = arange(23)
>>> await aany(aiterable)
TrueFor more, see the documentation.
>>> aiterable = arange(23)
>>> [batch async for batch in abatched(aiterable, n=3)]
[(0, 1, 2), (3, 4, 5), ..., (18, 19, 20), (21, 22)]For more, see the documentation.
>>> nums1 = arange(0, 3)
>>> nums2 = arange(3, 6)
>>> [num async for num in achain(nums1, nums2)]
[0, 1, 2, 3, 4, 5]For more, see the documentation.
>>> [num async for num in acount(start=23, step=4)]
[23, 27, 31, 35, 39, 43, 47, ...]For more, see the documentation.
>>> aiterable = arange(23)
>>> [num async for num in acycle(aiterable)]
[0, 1, ..., 22, 23, 0, 1, ..., 22, 23, ...]For more, see the documentation.
>>> aiterable = arange(23)
>>> await aempty(aiterable)
FalseFor more, see the documentation.
>>> aiterable = arange(4, 23)
>>> [(index, num) async for index, num in aenumerate(aiterable)]
[(0, 4), (1, 5), (2, 6), (3, 7), ..., (17, 21), (18, 22)]For more, see the documentation.
>>> aiterable = arange(23)
>>> await afirst(aiterable)
0For more, see the documentation.
>>> aiterable = arange(23)
>>> [num async for num in ahead(aiterable, n=4)]
[0, 1, 2, 3]For more, see the documentation.
>>> aiterable = arange(2003)
>>> [num async for num in aislice(aiterable, 4, 23)]
[4, 5, 6, 7, 8, ..., 20, 21, 22]For more, see the documentation.
>>> aiterable = arange(23)
>>> await alast(aiterable)
22For more, see the documentation.
>>> aiterable = arange(23)
>>> await alen(aiterable)
23For more, see the documentation.
>>> aiterable = arange(23)
>>> await amax(aiterable)
22For more, see the documentation.
>>> aiterable = arange(23)
>>> await amin(aiterable)
0For more, see the documentation.
>>> aiterable = arange(23)
>>> await aminmax(aiterable)
(0, 22)For more, see the documentation.
>>> iterable = [0, 1, 2, 3, 4, 5]
>>> aiterable = anextify(iterable)
>>> [num async for num in aiterable]
[0, 1, 2, 3, 4, 5]For more, see the documentation.
>>> aiterable = arange(23)
>>> await anth(aiterable, n=4)
4For more, see the documentation.
>>> aiterable = arange(23)
>>> [pair async for pair in apairwise(aiterable)]
[(0, 1), (1, 2), (2, 3), ..., (20, 21), (21, 22)]For more, see the documentation.
>>> [num async for num in apostpend(arange(4), 4)]
[0, 1, 2, 3, 4]For more, see the documentation.
>>> [num async for num in aprepend(0, arange(1, 5))]
[0, 1, 2, 3, 4]For more, see the documentation.
>>> [num async for num in arange(23)]
[0, 1, 2, 3, 4, ..., 19, 20, 21, 22]For more, see the documentation.
>>> [num async for num in arepeat(23, times=4)]
[23, 23, 23, 23]For more, see the documentation.
>>> aiterable = arange(23)
>>> [num async for num in areversed(aiterable)]
[22, 21, 20, 19, 18, ..., 4, 3, 2, 1, 0]For more, see the documentation.
>>> aiterable = arange(23)
>>> await asum(aiterable)
253For more, see the documentation.
>>> afunc = awaitify(lambda x: x * x)
>>> [num async for num in atabulate(afunc)]
[0, 1, 4, 9, 16, 25, 36, 49, ...]For more, see the documentation.
>>> aiterable = arange(23)
>>> [num async for num in atail(aiterable, n=4)]
[19, 20, 21, 22]For more, see the documentation.
>>> aiterable = arange(23)
>>> [triplet async for triplet in atriplewise(aiterable)]
[(0, 1, 2), (1, 2, 3), ..., (19, 20, 21), (20, 21, 22)]For more, see the documentation.
>>> aprint = awaitify(print)
>>> await aprint("4 -> 23")
4 -> 23For more, see the documentation.
>>> aiterable = arange(23)
>>> [window async for window in awindowed(aiterable, n=3)]
[(0, 1, 2), (1, 2, 3), ..., (19, 20, 21), (20, 21, 22)]For more, see the documentation.
>>> xs = arange(42)
>>> ys = arange(4, 23)
>>> [(x, y) async for x, y in azip(xs, ys)]
[(0, 4), (1, 5), (2, 6), ..., (18, 22)]MIT License, Copyright (c) 2025 Sergei Y. Bogdanov. See LICENSE file.