New
Learning Python
A thorough reference to Python language fundamentals, from syntax and data types to classes and advanced tools
by Mark Lutz
Published
2025
Practical Performant Programming for Humans
Profile, optimize, and scale Python code so your programs run faster without sacrificing readability or correctness.
High Performance Python gives you a systematic toolkit for finding and fixing bottlenecks in real Python programs. Starting with profiling to locate what actually matters, the book moves through memory management, efficient data structures, compiled extensions, concurrency, and parallel computing. Written by practitioners for practitioners, it gives you the mental models and hands-on techniques to make Python fast enough for the most demanding workloads.
Python is expressive and approachable, but production workloads have a way of exposing its limits. CPU-bound loops stall, memory balloons, I/O queues back up, and suddenly the language everyone loves becomes the thing your infrastructure team is asking you to replace. This book shows you how to fix that without throwing away your codebase.
Micha Gorelick and Ian Ozsvald walk you through a disciplined, evidence-driven approach to optimization. You start by learning to measure before you change anything. Profiling tools β cProfile, line_profiler, memory_profiler, perf β tell you where time and memory actually go, not where you assume they go. That distinction matters: most optimization effort spent without profiling is spent on the wrong code.
Once you know where the bottleneck is, the book equips you to address it precisely. You will learn why Python lists, sets, and dicts behave the way they do at the memory level, and how to choose the right structure for the job. You will learn when NumPy vectorization eliminates Python loops entirely, and when Cython or Numba can compile the remainder to near-C speed. You will understand the GIL β what it actually prevents, what it does not, and how to work around it with threading, multiprocessing, and async I/O patterns that match the problem you are solving.
The later chapters address large-scale and distributed workloads: efficient use of multiple cores, cluster-level parallelism, and patterns for keeping memory overhead predictable as data volumes grow. Throughout, the authors treat correctness and maintainability as non-negotiable constraints, not trade-offs.
This is the updated 2025 edition, revised to cover current Python versions and modern tooling. Whether you are optimizing a data pipeline, a web service under load, or a scientific simulation, the techniques here translate directly to production code you ship.
Establishes a mental model for why Python has the performance characteristics it does, covering the interpreter loop, the GIL, and the cost of dynamic typing. Sets up the measurement-first philosophy that runs through the rest of the book.
Walks through the main Python profiling tools β cProfile, line_profiler, and perf β with worked examples showing how to interpret their output and avoid common measurement mistakes.
Examines how Python allocates and stores sequence types under the hood, explaining when to prefer each and how to reduce per-object overhead through smarter data structure choices.
Explains the hash-table internals behind dict and set, covering memory cost, lookup performance, and the practical cases where choosing one over the other makes a measurable difference.
Shows how lazy evaluation with generators and itertools reduces peak memory use in data-processing pipelines, with before-and-after benchmarks on real workloads.
Covers NumPy array internals, broadcasting rules, and the patterns that eliminate Python-level loops, along with the common mistakes that silently negate vectorization gains.
Teaches you to identify code that benefits from compilation, then apply Cython type annotations and Numba JIT decorators to achieve near-C throughput on the hot paths that remain.
Distinguishes I/O-bound from CPU-bound concurrency, explains precisely what the GIL blocks, and shows idiomatic patterns using threading, multiprocessing, and asyncio for each problem class.
Covers the multiprocessing module, process pools, shared memory, and an introduction to cluster-level tools, with guidance on avoiding serialization overhead that can erase parallelism gains.
Synthesizes the book's techniques into a repeatable workflow: profile, hypothesize, change one thing, measure again. Includes a set of common anti-patterns and how to recognize them in your own code.
The 2025 edition covers Python 3.11 and 3.12, including changes to the GIL and the new free-threaded build. Earlier Python 3 syntax is used where it aids clarity, and all code samples are compatible with Python 3.10 and above.
No C knowledge is required for most chapters. The Cython and Numba chapters introduce just enough C-adjacent syntax to write annotated extensions, and each concept is explained from scratch.
The book assumes you are already comfortable writing Python programs β functions, classes, file I/O, and basic data structures. If you are still learning the language fundamentals, you will get more from this book after a few months of practical Python experience.
Yes. There is dedicated coverage of asyncio patterns, when async I/O helps versus when it does not, and how to combine it with other concurrency approaches without introducing hard-to-debug race conditions.
O'Reilly books in this format typically include code examples you can use in your own programs. Check the publisher's page for any companion repository linked from the book's official listing.
The 2025 edition is fully revised for Python 3.11 and 3.12, updates profiling tooling recommendations, expands the Numba and asyncio coverage, and adds new material on the experimental free-threaded CPython build.
New
A thorough reference to Python language fundamentals, from syntax and data types to classes and advanced tools
by Mark Lutz
New
A Hands-On, Project-Based Introduction to Programming in Python
by Eric Matthes
New
A Concise Desktop Reference for Python 3 β Language, Libraries, and Best Practices
by Alex Martelli, Anna Martelli Ravenscroft, Paul McGuire, Steve Holden
New
Clear, Concise, and Effective Programming with Python's Most Powerful Features