Concurrency is arguably the hardest concept for Python developers, because the important ideas already assume you understand the operating system underneath. In this chapter, we start from the kernel and system calls, build up processes, threads, race conditions, and the GIL, then work out when to reach for asyncio, threading, or multiprocessing, why a GPU beats a CPU on the same arithmetic, and how to get better at concurrent programming.
Scarf ran Haskell in production for seven years and is now moving to Python.
From kindergarten to PhD, this may be the most comprehensive chapter on Python functions. We start with the basics of defining and calling functions, learn how to write them well, then learn closures, decorators, recursion, and generators, all the way to theory of computation and how CPython executes functions under the hood.
Every if, loop, break, and continue in Python compiles down to the same tricks. We visualize the Python bytecode behind the control flow to understand how Python really works under the hood.
Picking the right data type in Python starts with the basics. In Part 1 of Python’s data types, we cover NoneType, bool, int, float, and complex.
Working with many objects at once requires the right container. In Part 2 of Python’s data types, we cover str, bytes, tuple, list, bytearray, set, and frozenset.
In Part 3 of Python’s data types, we cover dict and the new frozendict, Python 3.15’s built-in immutable mapping, plus how to choose the right data type for the job.
In Python, two variables equal to 256 share the same object, but two variables equal to 512 don’t. The reason is Python’s object model. In this chapter, we cover identity, type, and value; how assignment and name binding actually work; the small-integer cache; and why mutating a list changes both aliases while reassigning a string doesn’t.
Validation tells you if data is okay. Parsing turns it into a type the rest of your code can trust. We walk through what parsing and validation look like across OOP, ECS, and microservices in Python.
We explore Python testing from unit tests to integration and end-to-end tests, mutation testing, property-based testing, and MC/DC. We see why coverage alone can’t tell you if your tests are any good.