liveBook · Manning

Concurrency

As explained in Fast Python: High performance techniques for large datasets

Concurrency is the structuring or execution of multiple computational activities so their progress overlaps in time, whether or not they run simultaneously.

Concurrency lets tasks overlap in time, even when they do not run simultaneously: one task may be interrupted while another proceeds. Parallelism means tasks run at the same time. section 1.3.1 section 3.0

In CPython, the Global Interpreter Lock limits Python threads from executing simultaneously. Overlapping work can still be useful when tasks wait for I/O; asynchronous facilities can serve many concurrent requests without parallel execution. section 1.3.1 section 3.0

Serving concurrent requests

A single-computer MapReduce service can use asynchronous programming to process simultaneous user queries, while concurrent and parallel techniques address the data-processing work. section 3.0

Understanding sequential, concurrent, and parallel models. Sequential execution occurs when all tasks are executed in sequence and never interrupted. Concurrent execution with no parallelism adds the possibility of a task being interrupted by another and later resumed. Parallelism occurs when several tasks are run at the same time. Even with parallelism, it is quite common for preemption to still occur as the number of processors/cores may not be enough for all tasks. A dream scenario is when there are more processors than tasks: this allows parallel execution of all tasks without the need for any preemption.

Compare sequential, concurrent, and parallel task execution. section 3.0

How Fast Python: High performance techniques for large datasets covers it

How deep it goes
Defines overlap versus simultaneous execution and notes Python's GIL and asynchronous facilities, without developing implementation steps.
Examples
Illustrates overlapping tasks with I/O waits and simultaneous client queries to a single-computer MapReduce service.
What you can do after
Apply asynchronous programming to serve many concurrent requests without requiring parallel solutions.
How it connects
Connects concurrency to parallelism, multithreading, asynchronous programming, and the Global Interpreter Lock.

Also explained in

Compare how 23 books explain concurrency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fast Python: High performance techniques for large datasets. The section links point to the parts of the book it draws on.