Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leogregianin/python-concurrency-and-parallelism
Concurrency and Parallelism in Python: thread x multiprocess x async-io
https://github.com/leogregianin/python-concurrency-and-parallelism
asyncio openweathermap-api parallelism python python-concurrency thread weather
Last synced: about 18 hours ago
JSON representation
Concurrency and Parallelism in Python: thread x multiprocess x async-io
- Host: GitHub
- URL: https://github.com/leogregianin/python-concurrency-and-parallelism
- Owner: leogregianin
- License: mit
- Created: 2019-11-05T12:50:58.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-12-08T07:46:36.000Z (almost 2 years ago)
- Last Synced: 2024-05-01T14:43:12.979Z (6 months ago)
- Topics: asyncio, openweathermap-api, parallelism, python, python-concurrency, thread, weather
- Language: Python
- Homepage:
- Size: 47.9 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-concurrency-and-parallelism
Concurrency and parallelism in Python> Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once. **-- Rob Pike, co-inventor da linguagem Go - Concurrency is not Parallelism (it's better)**
>Ao preparar vários pratos ao mesmo tempo o cozinheiro está trabalhando de forma concorrente, porque normalmente ele só cuida de um prato por vez, mas vários estão sendo preparados ao mesmo tempo.
> Por outro lado, um fogão de 6 bocas permite aquecer 6 panelas em paralelo.
> Ou seja, o cozinheiro trabalha em modo concorrente e o fogão em modo paralelo. **-- [Garoa Hacker Clube](https://garoa.net.br/wiki/Python_Concorrente)**# Install packages
* pipenv install
or
* requests
* asyncio
* aiohttp
* httpx# Benchmarks
Benchmark name | (1) | (2) | (3) | (4) | (5) | (6)
-------------------------------------|----------:|----------:|----------:|----------:|----------:|----------:
synchronous (sync.py) | 17.36607 | 17.22630 | 15.45768 | 15.19582 | 5.01565 | 4.41665
thread with 5 workers (thread.py) | 3.24835 | 2.75820 | 1.84323 | 1.81323 | 0.50936 | 0.51072
thread with 50 workers (thread.py) | 0.62569 | 0.75663 | 0.57323 | 0.58774 | 0.29404 | 0.25039
parallelism (multiprocess.py) | 3.60770 | 3.31779 | 2.84597 | 2.70542 | 0.37044 | 0.36182
asynchronous coroutines (async.py) | 0.58660 | 0.60951 | 0.57161 | 0.57969 | 0.27758 | 0.23457* Time in seconds
* (1) with Python 3.6.5 (win32)
* (2) with Python 3.6.5 (win32)
* (3) with Python 3.8.0 (win32)
* (4) with Python 3.8.0 (win32)
* (5) with Python 3.7.4 (linux gcc 8.3.0)
* (6) with Python 3.7.4 (linux gcc 8.3.0)# References
* [en] [Coroutines and Tasks - Official Python Docs](https://docs.python.org/3/library/asyncio-task.html)
* [en] [threading — Thread-based parallelism - Official Python Docs](https://docs.python.org/3/library/threading.html)
* [en] [multiprocessing — Process-based parallelism - Official Python Docs](https://docs.python.org/3/library/multiprocessing.html)
* [en] [Speed Up Your Python Program With Concurrency](https://realpython.com/python-concurrency)
* [en] [An Intro to Threading in Python](https://realpython.com/intro-to-python-threading)
* [en] [Async IO in Python: A Complete Walkthrough](https://realpython.com/async-io-python)
* [en] [AsyncIO for the Working Python Developer - Yeray Diaz](https://hackernoon.com/asyncio-for-the-working-python-developer-5c468e6e2e8e)
* [pt-br] [AsyncIO - O futuro do Python mudou completamente! - Bruno Rocha](http://brunorocha.org/python/asyncio-o-futuro-do-python-mudou-completamente.html)