New
High Performance Python
Practical Performant Programming for Humans
by Ian Ozsvald, Micha Gorelick
Pages
1262
Published
2019
90 Specific Ways to Write Better Python
Master the idioms, patterns, and best practices that separate working Python code from production-quality Python code.
Effective Python gives you 90 concrete, independent items β each a specific technique, pattern, or pitfall β that make your Python code cleaner, faster, and easier to maintain. Written by Brett Slatkin, a senior engineer at Google, the book covers everything from generator expressions and concurrency primitives to metaclasses and memory management. Each item explains not just what to do, but why it works and what goes wrong when you ignore it.
Most Python developers learn the language by getting things to work. They pick up syntax, discover the standard library, and ship code that runs. But there is a significant gap between code that runs and code that a team can maintain, extend, and trust in production. Effective Python closes that gap.
Brett Slatkin organizes the book into 90 discrete, self-contained items. Each one targets a real decision you face when writing Python: which sequence type to reach for, when to use a generator instead of a list comprehension, how to write a class hierarchy that does not fight the language, and dozens more. You can read straight through or jump to the item you need today.
The book is organized into thematic sections that mirror how real programs grow in complexity:
Each item follows the same structure: a clear statement of the practice, a realistic code example showing the problematic pattern, the corrected version, and an explanation of the trade-offs. Nothing is hand-waved. If a technique has a cost, Slatkin tells you.
This is not a reference manual. It does not document every parameter of every function in the standard library. It is an opinionated, experience-backed guide to the decisions that separate beginner Python from the kind of Python that holds up under real pressure. If you already know the basics and want to write code that more senior engineers respect, this is the book to read next.
Learn the core style rules and mental model that define idiomatic Python, including how to use the Python version system, follow PEP 8 conventions, and prefer Python-native constructs over patterns borrowed from other languages.
Work with Python's most-used data structures correctly, covering slicing, starred unpacking, sorting, dictionary ordering guarantees, and when to use defaultdict or Counter instead of rolling your own logic.
Master the nuances of Python functions, including how closures capture variables, how default argument values are evaluated, and how keyword-only and positional-only parameters make call sites clearer and safer.
Replace verbose loops with comprehensions and generator expressions, learning when each form is appropriate and how to use itertools to compose lazy pipelines that handle arbitrarily large data sets.
Build class hierarchies that feel natural in Python, covering public and private attributes, the difference between inheritance and composition, how to use @property, and when abstract base classes add value.
Understand how Python constructs classes at runtime and use metaclasses, __init_subclass__, and descriptors to write the kind of introspective machinery that underpins frameworks and ORMs.
Navigate Python's concurrency options, from threads and the GIL through multiprocessing and subprocess to native coroutines and the asyncio event loop, with guidance on which model fits which class of problem.
Apply the practical engineering practices that keep production Python healthy: defensive exception handling, profiling with cProfile, memory measurement, and writing tests that catch regressions automatically.
Use unittest, mocks, and Python's built-in debugging and introspection tools to write test suites that are fast, deterministic, and actually informative when they fail.
Organize large Python codebases into well-structured packages, manage dependencies with virtual environments, and use type annotations and documentation conventions that help teammates contribute without introducing subtle bugs.
You should already be comfortable writing basic Python, including functions, classes, and standard library usage. The book is aimed at developers who know how Python works and want to use it more effectively, not at absolute beginners.
Yes. The third edition covers Python 3 throughout and does not maintain Python 2 compatibility. Specific items call out version differences where behavior changed meaningfully between Python 3.x releases.
No. Each of the 90 items is self-contained with its own code examples and explanation. You can read sequentially or jump directly to the items most relevant to what you are working on today.
The practices apply to any serious Python work. Data scientists who write reusable libraries, pipelines, or shared notebooks will find the sections on functions, classes, generators, and testing directly applicable.
Yes, there is a dedicated section on concurrency and parallelism covering threads, multiprocessing, and the asyncio event loop with concrete guidance on when to use each approach.
The length reflects 90 complete, standalone items rather than a single long narrative. Most items run 10 to 20 pages and can be read in a single sitting, making the book more approachable than its page count suggests.
New
Practical Performant Programming for Humans
by Ian Ozsvald, Micha Gorelick
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