One PostgreSQL database on a laptop takes about 23,000 New York taxi trips a second, sent one at a time, while the city’s yellow taxis averaged about 1.3 trips a second in 2024. In this chapter, we compare Kafka with RabbitMQ, Amazon SQS, Redis, and PostgreSQL, and see how Kafka works: its topics, partitions, offsets, consumer groups, batches, and segments. We also see how a crash can lose or repeat events, and how a team chooses between the five.
One SQL query on 41 million New York taxi trips in an Iceberg table takes 0.29 s with DuckDB, 0.51 s with Polars, and 5.66 s with Spark, all on one laptop. In this chapter, we see how DuckDB and Polars use every core of one machine, how the Google File System, MapReduce, and Hadoop store and process data on many machines, and how Spark works: its cache and lineage, the driver and executors, the query plan, tasks, stages, and shuffles. We also see when one machine is enough and when Spark is worth its costs.
After more than 20 years, World of Warcraft’s servers still struggle, and adding more servers can’t fix it. Through one PvP fight from 2006, we see what the game’s client and server each do, then why the work of a packed crowd grows at least with the square of its size, how realms, instances, shards, layers, and batching spread the load, and why the server’s processor is still the limit.
A folder of Parquet files is not a table. An interrupted write leaves a third of a month behind, two files with a different timestamp unit break the read, and a count that runs during a rewrite returns 82 million taxi trips instead of 41. In this chapter, we see how Apache Iceberg turns the same files into a table with ACID guarantees: manifests, manifest lists, metadata files, and a catalog, then hidden partitioning, atomic commits, time travel, schema evolution, and compaction, measured on New York’s taxi trips with PyIceberg, Polars, and DuckDB. We also compare Iceberg with Hive tables and Delta Lake.
Changing one line from CSV to Parquet makes reading the fares of ten million New York taxi trips 27 times faster, and the file is a sixth of the size. In this chapter, we measure why with Polars, DuckDB, PyArrow, and pandas: columnar storage, types in the file, the footer, encodings, pages, compression, predicate pushdown, and row group size. We also see where row storage still wins.
A short story about what Pythonic might mean, an idea that involves a fair amount of interpretation and subjectivity.
In the age of AI, syntax by itself is the least important part of object-oriented programming to focus on. In this chapter, we cover classes, instance and class attributes, static and class methods, properties, encapsulation, inheritance, composition, and polymorphism against a problem from production code, a rate limiter for alerts. Along the way, we see what the SOLID principles warn about, what inheritance costs, and why composition is the more flexible approach.
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.