Back to index
OtherAround 1,000 pages across 24 chapters, several months as a reference you return to·Around $70 in print, or included with an O'Reilly subscription

Fluent Python, Second Edition (Luciano Ramalho)

4.7

Not a second book and not a beginner book. It is the one you read when your code works but you suspect you are fighting the language, and it explains why every idiom you have been copying exists.

What We Liked

  • The data model chapters reframe the whole language and are worth the price by themselves
  • The type hints coverage in the second edition is the most practical treatment in print
  • Concurrency section covers threads, processes and asyncio together with honest guidance on which to use
  • Every claim comes with code you can run, and the examples are chosen with real care
  • Ramalho is candid about parts of Python he considers awkward, which builds trust

What Could Be Better

  • A thousand pages, and it genuinely reads like it
  • Useless and demoralising if you are not already comfortable writing Python
  • The metaprogramming chapters teach things most readers should never use in production
  • Second edition is from 2022, so newer typing and pattern matching developments are partly missed
  • Almost nothing about numerical Python, which is where a lot of AI work actually happens

Detailed review

Most people writing Python for machine learning learned the language incidentally, picking up syntax from tutorials until the code ran. That works for a surprisingly long time and it produces a particular kind of programmer, one who is fluent in the libraries and vague about the language underneath them. Fluent Python is the correction, and its central insight is structural. Python is not a bag of features.

It is a small set of protocols expressed through special methods, and once you see that, everything from why a for loop works on your custom object to why the with statement exists stops being arbitrary. Ramalho opens with the data model and the whole book proceeds from there. When you understand that len works because of dunder len, that iteration is a protocol you can implement, that context managers are two methods and a promise, you stop memorising idioms and start deriving them. I have watched this land for people and the change is visible.

Code gets shorter and more Pythonic within a fortnight, not because they learned tricks but because they finally understand what the language is asking for. The sequence and dictionary chapters do something similar for the built in types. Most working programmers have a fuzzy sense of when a list comprehension is right, why a tuple is not simply an immutable list, what a generator saves them, how dictionaries actually behave with respect to ordering and hashing. This book replaces all that folklore with mechanism, and the memory and performance material is grounded rather than hand waved.

The functions as objects section is where a lot of readers have their moment. Closures, decorators and the way Python treats callables get built up patiently until decorators stop being magic syntax you copy from Stack Overflow and become an obvious consequence of things you already understand. The second edition's headline addition is type hints, and it is the best treatment I have found anywhere. Typing in Python is a genuinely awkward subject, partly because it was retrofitted and partly because the ecosystem disagrees with itself about how much to use.

Ramalho covers the mechanics thoroughly and then does the more valuable thing, which is to be honest about where annotations pay for themselves and where they add ceremony for no return. That kind of judgement is exactly what a reference book usually refuses to offer. The concurrency chapters are also better than the norm. Threads, processes and asyncio are covered together rather than as separate religions, with clear discussion of what the global interpreter lock actually stops you doing and which model fits which shape of problem.

Anybody who has watched a team reach for asyncio because it sounded modern, on a workload that was plainly CPU bound, will appreciate having this in writing. Now the cost. It is a thousand pages, and unlike some large technical books it is dense throughout. This is not a weekend read and treating it as one will not work.

It also assumes real competence. If you are six months into Python, this book will make you feel stupid and you will get very little from it. Come back after a year of actually building things and it will feel like it was written for you specifically, because by then you will have accumulated the confusions it answers. The metaprogramming material at the end is the part I am most ambivalent about.

Descriptors, class metaprogramming and metaclasses are covered excellently and almost nobody should be writing them. Ramalho says as much, and the honest use case is reading framework internals rather than authoring your own. It is fascinating and it is the section most likely to inspire a junior engineer to do something regrettable to a codebase. The 2022 publication date is starting to show in the typing chapters specifically, since that part of Python has kept moving, and structural pattern matching gets less room than it now deserves.

The core material is essentially timeless because the data model does not change. For readers here for AI, note that this is a language book. There is nothing on numpy semantics, array broadcasting, or the numerical stack where a lot of your actual work will live. It makes you better at the Python around your model code, which matters more than people expect once you are writing pipelines and tooling rather than notebook cells.

My 4.7 is for a book with no real competition in its niche. It is long, it is demanding, and it is the clearest single upgrade available to an intermediate Python programmer. Do not buy it as your second book. Buy it as your fifth, when you have enough scar tissue to recognise what it is fixing.

[ final ]

The verdict.

Essential once you have a year of Python behind you. Read the first half properly, keep the second half on the shelf for when you need it.