Skip to main content

# aiolib


## Description

The main purpose of this lib is to provide *asyncio* compatbile alternatives for items of the standard library that aren't asyncio compatible. E.g. `itertools.chain.from_iterable()` doesn't work with `async_generators`, etc.

I hope/guess the stdlib will catch up with this sooner or later. This lib is for those who need a shim as soon as possible.

If you find something in the standard lib that doesn't work or play well with asyncio, please go ahead and add your replecement/wrapper!


## Requirements

aiolib requires Python `>= 3.6`


## Install

pip install aiolib

or

pipenv install aiolib


## Library Documentation


### builtins

#### `aenumerate`

Async version of: [enumerate](https://docs.python.org/3.6/library/functions.html#enumerate)

Example:

```python

async for i in aenumerate(chain(a_gen, range(10))):
print(i)

```

### itertools


#### `itertools.chain(*iterables)`

Async version of: [chain](https://docs.python.org/3.6/library/itertools.html#itertools.chain) in the stdlib.

This function can handle `AsyncGeneratorType`.

Example:

```python
# Use with async_generator:
async for i in chain(my_async_gen1, my_async_gen2):
print(i)

# Allows for mixing normal generators with async generators:
async for i in chain(my_async_gen, range(10)):
print(i)
```


#### `itertools.chain_from_iterable(iterable)`

Async version of: [from_iterable](https://docs.python.org/3.6/library/itertools.html#itertools.chain.from_iterable) in the stdlib.

This function can handle `AsyncGeneratorType`.

Example:

```python
# Use with async_generator:
async for i in chain_from_iterable(my_async_generator):
print(i)

# Works with normal items as well:
async for i in chain_from_iterable([range(10)]):
print(i)
```


### More items to come

Pull requests appreciated!



## Development

Just clone the repo and run:

pipenv install --dev

This project uses [yapf](https://github.com/google/yapf), but I don't really care how you format your pull requests. It would be auto-formatted later.



Release files for aiolib 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for aiolib 0.0.2
File Interpreter ABI Platform
aiolib-0.0.2-py3-none-any.whl Python 3 none any Details

Release files / aiolib-0.0.2-py3-none-any.whl

Download URL aiolib-0.0.2-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3fb7e1fafd952c022e47663ff45e93a86627996260f4bb677633dcaf0fc8749
BLAKE2b-256 checksum
How to use checksums
00651f3b99a04652fda8178067070df0e56d4d21a47639d8e884b4ca9fc47703
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page