aioplus
=======
|PyPI Version| |PyPI Downloads| |License| |Python Version| |Documentation|
Key Features
------------
* ``builtins``, ``itertools`` and ``more-itertools`` — but asynchronous;
* Seamless *sync*-*async* bridging (``awaitify``, ``anextify``, etc.);
* Early returns never cause unawaited coroutine warnings.
Getting Started
---------------
Installation
~~~~~~~~~~~~
The library is available as
`aioplus `__ on PyPI:
.. code:: shell
pip install aioplus
Usage
~~~~~
CallerThreadExecutor
--------------------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> executor = CallerThreadExecutor()
>>> loop = asyncio.new_event_loop()
>>> loop.set_default_executor(executor)
aall
----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await aall(aiterable)
False
aany
----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await aany(aiterable)
True
abatched
--------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> [batch async for batch in abatched(aiterable, n=3)]
[(0, 1, 2), (3, 4, 5), ..., (18, 19, 20), (21, 22)]
acount
------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> [num async for num in acount(start=23, step=4)]
[23, 27, 31, 35, 39, 43, 47, ...]
acycle
------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> [num async for num in acycle(aiterable)]
[0, 1, ..., 22, 23, 0, 1, ..., 22, 23, ...]
aenumerate
----------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> 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)]
afirst
------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await afirst(aiterable)
0
ahead
-----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> [num async for num in ahead(aiterable, n=4)]
[0, 1, 2, 3]
aislice
-------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(2003)
>>> [num async for num in aislice(aiterable, 4, 23)]
[4, 5, 6, 7, 8, ..., 20, 21, 22]
alast
-----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await alast(aiterable)
22
alen
----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await alen(aiterable)
23
amax
----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await amax(aiterable)
22
amin
----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await amin(aiterable)
0
aminmax
-------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await aminmax(aiterable)
(0, 22)
anextify
--------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> iterable = [0, 1, 2, 3, 4, 5]
>>> aiterable = anextify(iterable)
>>> [num async for num in aiterable]
[0, 1, 2, 3, 4, 5]
anth
----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await anth(aiterable, n=4)
4
apairwise
---------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> [pair async for pair in apairwise(aiterable)]
[(0, 1), (1, 2), (2, 3), ..., (20, 21), (21, 22)]
arange
------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> [num async for num in arange(23)]
[0, 1, 2, 3, 4, ..., 19, 20, 21, 22]
arepeat
-------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> [num async for num in arepeat(23, times=4)]
[23, 23, 23, 23]
areversed
---------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> [num async for num in areversed(aiterable)]
[22, 21, 20, 19, 18, ..., 4, 3, 2, 1, 0]
asum
----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> await asum(aiterable)
253
atail
-----
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> [num async for num in atail(aiterable, n=4)]
[19, 20, 21, 22]
atriplewise
-----------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> [triplet async for triplet in atriplewise(aiterable)]
[(0, 1, 2), (1, 2, 3), ..., (19, 20, 21), (20, 21, 22)]
awaitify
--------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aprint = awaitify(print)
>>> await aprint("4 -> 23")
4 -> 23
awindowed
---------
For more, see the :doc:`documentation `.
.. code-block:: python
>>> aiterable = arange(23)
>>> [window async for window in awindowed(aiterable, n=3)]
[(0, 1, 2), (1, 2, 3), ..., (19, 20, 21), (20, 21, 22)]
.. toctree::
:caption: API Reference
:hidden:
:maxdepth: 1
CallerThreadExecutor
aall
aany
abatched
acount
acycle
aenumerate
afirst
ahead
aislice
alast
alen
amax
amin
aminmax
anextify
anth
apairwise
arange
arepeat
areversed
asum
atail
atriplewise
awaitify
awindowed
License
-------
MIT License, Copyright (c) 2025 Sergei Y. Bogdanov. See
`LICENSE `__ file.
.. |PyPI Version| image:: https://img.shields.io/pypi/v/aioplus.svg?color=green
:target: https://pypi.org/project/aioplus/
.. |PyPI Downloads| image:: https://img.shields.io/pypi/dm/aioplus.svg?color=green
:target: https://pypi.org/project/aioplus/
.. |License| image:: https://img.shields.io/pypi/l/aioplus.svg?color=green
:target: https://github.com/syubogdanov/aioplus/tree/main/LICENSE
.. |Python Version| image:: https://img.shields.io/pypi/pyversions/aioplus.svg?color=green
:target: https://pypi.org/project/aioplus/
.. |Documentation| image:: https://img.shields.io/readthedocs/aioplus?style=flat&color=green
:target: https://aioplus.readthedocs.io/