High Performance Python
High Performance Python
Summary:
Introduction
The book «High Performance Python» by Micha Gorelick and Ian Ozsvald is a practical guide to optimizing Python code, published in 2020 (second edition). In a world where Python is often criticized for its speed, this book proves that with the right tools and approaches, Python can be not only convenient but also fast. At 464 pages, it allows for a detailed examination of both fundamental concepts and advanced techniques.
What the book is about
The book is dedicated to improving the performance of Python applications. The authors start with the basics: how to measure code execution speed using profiling (cProfile, line_profiler, memory_profiler). They then move on to practical acceleration methods: using data structures, vectorization with NumPy, compilation with Cython and Numba, parallelism and asynchrony (asyncio, multiprocessing, threading), working with GPUs (CUDA), and distributed computing. Special attention is given to working with big data and optimizing input/output.
Who this book is for
The book is aimed at intermediate and advanced Python developers who are already familiar with the basics of the language and want to take their projects to a new level of performance. It will be useful for:
- Data Scientists and machine learning engineers working with large volumes of data;
- Backend developers creating high-load services;
- Systems programmers looking to optimize bottlenecks in code;
- Students and researchers who need to speed up computations.
What the reader will learn
After reading, the reader will be able to:
- Profile code and find bottlenecks using line_profiler, memory_profiler, and flame graphs;
- Efficiently use lists, dictionaries, sets, and other data structures;
- Apply NumPy for vectorizing operations and achieving 10–100x speedups;
- Compile critical code sections with Cython and Numba;
- Implement multithreading and multiprocessing while avoiding locks;
- Use asyncio for asynchronous I/O;
- Work with GPUs via CUDA (PyCUDA, Numba) for parallel computing;
- Optimize disk and network operations (buffering, mmap, compression);
- Design distributed systems with Dask and Spark.
Strengths
The main advantage of the book is its practical focus. Each chapter contains real-world examples, performance measurements, and comparisons of approaches. The authors don't just provide theory; they show how to measure the effect of optimization. The second edition (2020) has been updated: sections on asyncio, Numba, and Dask have been added, and examples have been improved for Python 3.8+. The book is written in a lively style, with complex concepts explained through metaphors and visualizations. The chapter on profiling deserves special mention—it provides a clear methodology that can be applied to any project.
Who it is recommended for
I recommend this book to anyone who has encountered performance issues in Python and wants to approach solving them systematically. It will be useful both for beginners in optimization (thanks to the introductory chapters) and for experienced developers wanting to master modern tools (Numba, Dask, asyncio). If you write in Python and think about speed—this book will become your desktop reference.