Skip to content

Concurrency and Parallelism in Python: thread x multiprocess x async-io

License

Notifications You must be signed in to change notification settings

leogregianin/python-concurrency-and-parallelism

Repository files navigation

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

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

About

Concurrency and Parallelism in Python: thread x multiprocess x async-io

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages