Skip to main content

No project description provided

Project description


# aioshim


## Description

The main purpose of this lib is to provide *asyncio* compatible versions of the functions in the standard library. E.g. `itertools.chain()` doesn't work with `async_generators`, etc.

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

This could be a central repo for all such asyncio related shims.


## Requirements

aioshim requires Python `>= 3.6`


## Install

pip install aioshim

or

pipenv install aioshim


## Development

Just clone the repo and run:

pipenv install --dev

This project uses [yapf](https://github.com/google/yapf) formatter.


# 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: [itertools.chain](https://docs.python.org/3.6/library/itertools.html#itertools.chain)

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: [itertools.chain.from_iterable](https://docs.python.org/3.6/library/itertools.html#itertools.chain.from_iterable)

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!



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

aioshim-0.0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file aioshim-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for aioshim-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 215cf1053b8c8eb7cdefbf9d4a621df21d21c41b5edef497be7073ae7ba5ff59
MD5 6a8dcd9c5ecaae2d7311d7235ccfe3a4
BLAKE2b-256 c63006803b723936cd3326b381e6fda6330ca422327ab612d909a8c60ec7f9f1

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