Skip to content

Concurrent Programming Primer, for CPython Developers

Note: this document was written with extensive LLM agent assistance.

This primer explains concurrent C programming and the mechanisms used by free-threaded CPython. Chapters 1–8 cover general concepts, chapters 9–13 cover CPython, and chapter 14 helps you choose a technique.

Start with shared mutable memory, or use the contents and topic index to find a specific subject. The glossary defines concurrency terms and links to relevant sections. For books, articles, talks, and reference material, see further reading.

Contents

  1. The basic problem: shared mutable memory
  2. The C abstract machine and undefined behavior
  3. The C memory model
  4. Atomic operations
  5. Synchronization
  6. Concurrency and performance
  7. Lock-free algorithms
  8. Safe memory reclamation
  9. CPython's concurrency model
  10. PyMutex
  11. CPython critical sections
  12. Stop-the-world
  13. QSBR in CPython
  14. Choosing a technique

The source for this site is on GitHub.

Markdown source