Question presented to candidate: "People use concurrency and parallelism as if they were the same word. What is the actual difference, and what does each one look like in Python β with threads, asyncio and multiprocessing?"
What a strong answer should cover:
- Concurrency is about structure: several tasks are in progress during the same period and their steps interleave, possibly on one core. Parallelism is about execution: several steps run at the same instant on different cores.
- Parallelism needs more than one core; concurrency does not. Every parallel program is concurrent, not every concurrent program is parallel.
- In CPython with the GIL, threads give concurrency but not parallel Python bytecode; blocking I/O and many C extensions release the GIL, so waits overlap.
- asyncio is concurrency on a single thread (cooperative, switches only at
await); multiprocessing (orProcessPoolExecutor) gives parallelism with one interpreter and one GIL per process. - Which one you need follows from the workload: waiting (I/O-bound) is helped by concurrency; computing (CPU-bound) needs parallelism.
- Version detail: the free-threaded build (experimental in 3.13, officially supported but optional in 3.14) lets threads run Python code in parallel.
Code / implementation expected: Optional β sketch interleaving vs. parallel execution, or explain why four CPU-bound threads are not faster.