skip to navigation
skip to content

paco 0.1.11

Small utility library for coroutine-based asynchronous generic programming


Small and idiomatic utility library for coroutine-driven asynchronous generic programming in Python +3.4.

Built on top of asyncio, paco provides missing capabilities from Python stdlib in order to write asynchronous cooperative multitasking in a nice-ish way. Also, paco aims to port some of functools and itertools standard functions to the asynchronous world.

paco can be your utility belt to deal with asynchronous, I/O-bound, non-blocking concurrent code in a cleaner and idiomatic way.


  • Simple and idiomatic API, extending Python stdlib with async coroutines gotchas.
  • Built-in configurable control-flow concurrency support (throttle).
  • No fancy abstractions: it just works with the plain async coroutines.
  • Useful iterables, decorators, functors and convenient helpers.
  • Coroutine-based functional helpers: compose, throttle, partial, timeout, times, until, race…
  • Asynchronous coroutine port of Python built-in functions: filter, map, dropwhile, filterfalse, reduce
  • Supports asynchronous iterables and generators (PEP0525)
  • Concurrent iterables and higher-order functions.
  • Better asyncio.gather() and asyncio.wait() with optional concurrency control and ordered results.
  • Works with both async/await and yield from coroutines syntax.
  • Reliable coroutine timeout limit handler via context manager.
  • Designed for intensive I/O-bound concurrent non-blocking tasks.
  • Good interoperability with asyncio and Python stdlib functions.
  • Composable pipelines of functors for transducers-like chain via | operator overloading.
  • Small and dependency free.
  • Compatible with Python +3.4.


Using pip package manager:

pip install --upgrade paco

Or install the latest sources from Github:

pip install -e git+git://



Asynchronously and concurrently execute multiple HTTP requests.

import paco
import aiohttp

async def fetch(url):
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as res:
            return res

async def fetch_urls():
    urls = [

    # Map concurrent executor with concurrent limit of 3
    responses = await, urls, limit=3)

    for res in responses:
        print('Status:', res.status)

# Run in event loop

Concurrent pipeline-style composition of transform functors over an iterable object.

import paco

async def filterer(x):
    return x < 8

async def mapper(x):
    return x * 2

async def drop(x):
    return x < 10

async def reducer(acc, x):
    return acc + x

async def task(numbers):
    return await (numbers
                   | paco.filter(filterer)
                   | paco.dropwhile(drop)
                   | paco.reduce(reducer, initializer=0))

# Run in event loop
number =, 2, 3, 4, 5, 6, 7, 8, 9, 10)))
print('Number:', number) # => 36


MIT - Tomas Aparicio


v0.1.11 / 2017-01-28

  • feat(api): add paco.interval function.

v0.1.10 / 2017-01-11

  • fix(, fixed return_exceptions kwarg
  • fix( add author email
  • fix(Makefile): remove package file

v0.1.9 / 2017-01-06

  • feat(api): add identity function
  • feat(#31): add thunk function
  • feat(package): add wheel package distribution
  • refactor(wraps): simplify implementation
  • fix(History): remove indentation

v0.1.8 / 2016-12-29

  • feat(requirements): force upgrade setuptools
  • feat(#29): support async iterable and generators
  • fix(docs): link to examples
  • chore(travis): use Python 3.6 stable release

0.1.7 / 2016-12-18

  • feat(#26): add curry function.

0.1.6 / 2016-12-11

  • feat(pipe): isolate pipe operator overload code
  • refactor: decorator and util functions
  • feat(#11): timeout limit context manager.
  • refactor(core): several minor refactors
  • fix(docs): comment out latex sphinx settings
  • fix(docs): use current package version
  • Documentation examples improvements (#27)
  • feat(history): update
  • feat: add pool length magic method

0.1.5 (2016-12-04)

  • fix(#25): allow empty iterables in iterators functions, such as map, filter, reduce.

0.1.4 (2016-11-28)

  • fix(#24): explicitly pass loop instance to asyncio.wait.

0.1.3 (2016-10-27)

  • feat(#17): add flat_map function.
  • feat(#18): add pipeline-style operator overloading composition.

0.1.2 (2016-10-25)

  • fix( fix pip installation.
  • refactor(api): minor refactors in several functions and tests.

0.1.1 (2016-10-24)

  • refactor(name): use new project name.

0.1.0 (2016-10-23)

  • First version (beta)
File Type Py Version Uploaded on Size
paco-0.1.11-py2.py3-none-any.whl (md5) Python Wheel 3.6 2017-01-28 44KB
paco-0.1.11.tar.gz (md5) Source 2017-01-28 25KB