backend / README.md

Async and concurrency

1 min read index source

Async and concurrency

Top-three Python backend interview topic. Read in order — each file assumes the previous ones.

Foundations

# File Covers
01 01_gil.md what the GIL is, why it exists, what it costs
02 02_concurrency_vs_parallelism.md the distinction, and which Python tool gives you which
03 03_threads_vs_processes.md OS-level: address space, scheduling, cost
04 04_context_switch.md what a switch actually costs, OS vs coroutine

Asyncio

# File Covers
05 05_async_python_coroutines.md async def, awaitables, how a coroutine runs
06 06_event_loop_internals.md selectors, yield points, uvloop, Python vs JS loops
07 07_asyncio_vs_threads.md the comparison, with hybrid patterns
12 12_taskgroup_structured_concurrency.md TaskGroup vs gather, and picking the right primitive
13 13_cancellation_timeouts_errors.md CancelledError, asyncio.timeout, shield, ExceptionGroup
17 17_anyio_trio_structured.md anyio/Trio, and why libraries target them

Choosing a model, and offloading

# File Covers
08 08_cpu_io_tasks.md classifying the workload — the decision that drives everything
09 09_when_to_use_processes.md when processes are the answer
14 14_run_in_executor_to_thread.md asyncio.to_thread, executors, sync drivers in async code
15 15_concurrent_futures.md the unified pool API
16 16_process_pool_executor.md process pools, pickling, IPC costs

Coordination

# File Covers
10 10_synchronization_primitives.md locks, semaphores, events, conditions — across all three models
11 11_asyncio_queue_vs_threading_queue.md queues, backpressure, and not mixing the two

Runnable examples: _examples/.

The 2026 headline

Free-threaded CPython is officially supported as of Python 3.14 (PEP 779) - no longer experimental, though still an opt-in build. Python 3.14 also added stdlib subinterpreters (PEP 734), so “threads, async, or processes?” is now a four-way question. Covered in 01_gil.md.