Python › Concurrency (asyncio/threading/multiprocessing)
What is the fundamental difference between concurrency and parallelism, and how does this map to Python's threading versus multiprocessing modules?
BeginnerAnswer
Concurrency means multiple tasks make PROGRESS over overlapping time periods (not necessarily simultaneously); parallelism means tasks run LITERALLY AT THE SAME INSTANT on different CPU cores. Python's threading module provides concurrency (constrained by the GIL for CPU-bound work), while multiprocessing achieves TRUE parallelism by using separate OS processes, each with its own Python interpreter and GIL.
# threading: concurrent, but GIL-limited for CPU-bound work
import threading
threading.Thread(target=cpu_bound_task).start()
# multiprocessing: true parallelism, separate processes
import multiprocessing
multiprocessing.Process(target=cpu_bound_task).start()Real-world example Choosing multiprocessing for a CPU-heavy image-processing batch job to actually utilize multiple CPU cores.