{"id":13501608,"url":"https://github.com/h2non/paco","last_synced_at":"2025-04-05T14:09:59.103Z","repository":{"id":57450199,"uuid":"70951500","full_name":"h2non/paco","owner":"h2non","description":"Small utility library for coroutine-driven asynchronous generic programming in Python","archived":false,"fork":false,"pushed_at":"2024-02-24T17:35:57.000Z","size":196,"stargazers_count":202,"open_issues_count":8,"forks_count":13,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-18T11:25:11.608Z","etag":null,"topics":["asynchronous","asyncio","coroutines","generic-programming","library","python","utility"],"latest_commit_sha":null,"homepage":"http://paco.rtfd.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/h2non.png","metadata":{"files":{"readme":"README.rst","changelog":"History.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-14T22:27:13.000Z","updated_at":"2024-02-24T17:33:28.000Z","dependencies_parsed_at":"2024-06-21T04:11:34.821Z","dependency_job_id":null,"html_url":"https://github.com/h2non/paco","commit_stats":{"total_commits":136,"total_committers":6,"mean_commits":"22.666666666666668","dds":0.05147058823529416,"last_synced_commit":"41bf91e29c5409bfd90816bd37eafd42b083117d"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h2non%2Fpaco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h2non%2Fpaco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h2non%2Fpaco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h2non%2Fpaco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/h2non","download_url":"https://codeload.github.com/h2non/paco/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345856,"owners_count":20924102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","asyncio","coroutines","generic-programming","library","python","utility"],"created_at":"2024-07-31T22:01:43.437Z","updated_at":"2025-04-05T14:09:59.075Z","avatar_url":"https://github.com/h2non.png","language":"Python","readme":"paco |PyPI| |Coverage Status| |Documentation Status| |Stability| |Quality| |Versions|\n=====================================================================================\n\nSmall and idiomatic utility library for coroutine-driven asynchronous generic programming in Python.\n\nBuilt on top of `asyncio`_, ``paco`` provides missing capabilities from Python `stdlib`\nin order to write asynchronous cooperative multitasking in a nice-ish way.\nAlso, paco aims to port some of `functools`_ and `itertools`_ standard functions to the asynchronous world.\n\n``paco`` can be your utility belt to deal with asynchronous, I/O-bound, non-blocking concurrent code in a cleaner and idiomatic way.\n\nFeatures\n--------\n\n-  Simple and idiomatic API, extending Python ``stdlib`` with async coroutines gotchas.\n-  Built-in configurable control-flow concurrency support (throttle).\n-  No fancy abstractions: it just works with the plain asynchronous coroutines.\n-  Useful iterables, decorators, functors and convenient helpers.\n-  Coroutine-based functional helpers: ``compose``, ``throttle``, ``partial``, ``timeout``, ``times``, ``until``, ``race``...\n-  Asynchronous coroutines port of Python built-in functions: `filter`, `map`, `dropwhile`, `filterfalse`, `reduce`...\n-  Supports asynchronous iterables and generators (`PEP0525`_)\n-  Concurrent iterables and higher-order functions.\n-  Better ``asyncio.gather()`` and ``asyncio.wait()`` with optional concurrency control and ordered results.\n-  Works with both `async/await`_ and `yield from`_ coroutines syntax.\n-  Reliable coroutine timeout limit handler via context manager.\n-  Designed for intensive I/O bound concurrent non-blocking tasks.\n-  Good interoperability with ``asyncio`` and Python ``stdlib`` functions.\n-  `Composable pipelines`_ of functors via ``|`` operator overloading.\n-  Small and dependency free.\n-  Compatible with Python +3.4.\n\nInstallation\n------------\n\nUsing ``pip`` package manager:\n\n.. code-block:: bash\n\n    pip install --upgrade paco\n\nOr install the latest sources from Github:\n\n.. code-block:: bash\n\n    pip install -e git+git://github.com/h2non/paco.git#egg=paco\n\n\nAPI\n---\n\n- paco.ConcurrentExecutor_\n- paco.apply_\n- paco.compose_\n- paco.concurrent_\n- paco.constant_\n- paco.curry_\n- paco.defer_\n- paco.dropwhile_\n- paco.each_\n- paco.every_\n- paco.filter_\n- paco.filterfalse_\n- paco.flat_map_\n- paco.gather_\n- paco.identity_\n- paco.interval_\n- paco.map_\n- paco.once_\n- paco.partial_\n- paco.race_\n- paco.reduce_\n- paco.repeat_\n- paco.run_\n- paco.series_\n- paco.some_\n- paco.throttle_\n- paco.thunk_\n- paco.timeout_\n- paco.TimeoutLimit_\n- paco.times_\n- paco.until_\n- paco.wait_\n- paco.whilst_\n- paco.wraps_\n\n\n.. _paco.ConcurrentExecutor: http://paco.readthedocs.io/en/latest/api.html#paco.ConcurrentExecutor\n.. _paco.apply: http://paco.readthedocs.io/en/latest/api.html#paco.apply\n.. _paco.compose: http://paco.readthedocs.io/en/latest/api.html#paco.compose\n.. _paco.concurrent: http://paco.readthedocs.io/en/latest/api.html#paco.concurrent\n.. _paco.constant: http://paco.readthedocs.io/en/latest/api.html#paco.constant\n.. _paco.curry: http://paco.readthedocs.io/en/latest/api.html#paco.curry\n.. _paco.defer: http://paco.readthedocs.io/en/latest/api.html#paco.defer\n.. _paco.dropwhile: http://paco.readthedocs.io/en/latest/api.html#paco.dropwhile\n.. _paco.each: http://paco.readthedocs.io/en/latest/api.html#paco.each\n.. _paco.every: http://paco.readthedocs.io/en/latest/api.html#paco.every\n.. _paco.filter: http://paco.readthedocs.io/en/latest/api.html#paco.filter\n.. _paco.filterfalse: http://paco.readthedocs.io/en/latest/api.html#paco.filterfalse\n.. _paco.flat_map: http://paco.readthedocs.io/en/latest/api.html#paco.flat_map\n.. _paco.gather: http://paco.readthedocs.io/en/latest/api.html#paco.gather\n.. _paco.identity: http://paco.readthedocs.io/en/latest/api.html#paco.identity\n.. _paco.interval: http://paco.readthedocs.io/en/latest/api.html#paco.interval\n.. _paco.map: http://paco.readthedocs.io/en/latest/api.html#paco.map\n.. _paco.once: http://paco.readthedocs.io/en/latest/api.html#paco.once\n.. _paco.partial: http://paco.readthedocs.io/en/latest/api.html#paco.partial\n.. _paco.race: http://paco.readthedocs.io/en/latest/api.html#paco.race\n.. _paco.reduce: http://paco.readthedocs.io/en/latest/api.html#paco.reduce\n.. _paco.repeat: http://paco.readthedocs.io/en/latest/api.html#paco.repeat\n.. _paco.run: http://paco.readthedocs.io/en/latest/api.html#paco.run\n.. _paco.series: http://paco.readthedocs.io/en/latest/api.html#paco.series\n.. _paco.some: http://paco.readthedocs.io/en/latest/api.html#paco.some\n.. _paco.throttle: http://paco.readthedocs.io/en/latest/api.html#paco.throttle\n.. _paco.thunk: http://paco.readthedocs.io/en/latest/api.html#paco.thunk\n.. _paco.timeout: http://paco.readthedocs.io/en/latest/api.html#paco.timeout\n.. _paco.TimeoutLimit: http://paco.readthedocs.io/en/latest/api.html#paco.TimeoutLimit\n.. _paco.times: http://paco.readthedocs.io/en/latest/api.html#paco.times\n.. _paco.until: http://paco.readthedocs.io/en/latest/api.html#paco.until\n.. _paco.wait: http://paco.readthedocs.io/en/latest/api.html#paco.wait\n.. _paco.whilst: http://paco.readthedocs.io/en/latest/api.html#paco.whilst\n.. _paco.wraps: http://paco.readthedocs.io/en/latest/api.html#paco.wraps\n\n\nExamples\n^^^^^^^^\n\nAsynchronously and concurrently execute multiple HTTP requests.\n\n.. code-block:: python\n\n    import paco\n    import aiohttp\n\n    async def fetch(url):\n        async with aiohttp.ClientSession() as session:\n            async with session.get(url) as res:\n                return res\n\n    async def fetch_urls():\n        urls = [\n            'https://www.google.com',\n            'https://www.yahoo.com',\n            'https://www.bing.com',\n            'https://www.baidu.com',\n            'https://duckduckgo.com',\n        ]\n\n        # Map concurrent executor with concurrent limit of 3\n        responses = await paco.map(fetch, urls, limit=3)\n\n        for res in responses:\n            print('Status:', res.status)\n\n    # Run in event loop\n    paco.run(fetch_urls())\n\n\n\nConcurrent pipeline-style composition of transform functors over an iterable object.\n\n.. code-block:: python\n\n    import paco\n\n    async def filterer(x):\n        return x \u003c 8\n\n    async def mapper(x):\n        return x * 2\n\n    async def drop(x):\n        return x \u003c 10\n\n    async def reducer(acc, x):\n        return acc + x\n\n    async def task(numbers):\n        return await (numbers\n                       | paco.filter(filterer)\n                       | paco.map(mapper)\n                       | paco.dropwhile(drop)\n                       | paco.reduce(reducer, initializer=0))\n\n    # Run in event loop\n    number = paco.run(task((1, 2, 3, 4, 5, 6, 7, 8, 9, 10)))\n    print('Number:', number) # =\u003e 36\n\nLicense\n-------\n\nMIT - Tomas Aparicio\n\n.. _asynchronous: http://python.org\n.. _asyncio: https://docs.python.org/3.5/library/asyncio.html\n.. _Python: http://python.org\n.. _annotated API reference: https://h2non.github.io/paco\n.. _async/await: https://www.python.org/dev/peps/pep-0492/\n.. _yield from: https://www.python.org/dev/peps/pep-0380/\n.. _Composable pipelines: #examples\n.. _itertools: https://docs.python.org/3/library/itertools.html\n.. _functools: https://docs.python.org/3/library/functools.html\n.. _PEP0525: https://www.python.org/dev/peps/pep-0525/\n\n.. |PyPI| image:: https://img.shields.io/pypi/v/paco.svg?maxAge=2592000?style=flat-square\n   :target: https://pypi.python.org/pypi/paco\n.. |Coverage Status| image:: https://coveralls.io/repos/github/h2non/paco/badge.svg?branch=master\n   :target: https://coveralls.io/github/h2non/paco?branch=master\n.. |Documentation Status| image:: https://img.shields.io/badge/docs-latest-green.svg?style=flat\n   :target: http://paco.readthedocs.io/en/latest/?badge=latest\n.. |Quality| image:: https://codeclimate.com/github/h2non/paco/badges/gpa.svg\n   :target: https://codeclimate.com/github/h2non/paco\n.. |Stability| image:: https://img.shields.io/pypi/status/paco.svg\n   :target: https://pypi.python.org/pypi/paco\n.. |Versions| image:: https://img.shields.io/pypi/pyversions/paco.svg\n   :target: https://pypi.python.org/pypi/paco\n","funding_links":[],"categories":["Python","其他"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh2non%2Fpaco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh2non%2Fpaco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh2non%2Fpaco/lists"}