shlogg · Early preview
Yosuke Hanaoka @yoshan0921

Python Concurrency Options: Asyncio Vs Threading Vs Multiprocessing

Concurrency in Python: Use **asyncio** for I/O bound tasks & **multiprocessing** for CPU bound tasks due to Global Interpreter Lock (GIL) limitation. **threading** can be used but with caution.

Introduction

Concurrency is one of the approaches that can drastically improve the performance of our Python programs, which can be achieved in Python using numerous methods and modules. In this blog post, I would like to summarize my understanding and share the results of my attempts to speed up Python programs using the following three basic libraries.

asyncio: Coroutine-Based Concurrency
threading: Thread-Based Concurrency
multiprocessing: Process-Based Concurrency

  
  
  What is Concurrency?

Before we get to the main topic of concurrent programming, please let me clarify the definitio...