◐ Shell
clean mode source ↗

Effective Python › The Book: Second Edition

What This Book Covered

Effective Python: Second Edition Book Cover

You are reading about a previous, old version of this book. The third edition of this book (released in November, 2024) is focused exclusively on Python 3, up to and including version 3.13.

Most of the original items from the second edition have been revised and included in the third edition, but many have undergone substantial updates. For some items my advice has completely changed due best practices evolving as Python has matured.

If you’re still using an older version of Python 3 (such as 3.8 or earlier), the second edition of the book (released in November 2019) might still be useful to you.

Buy the Second Edition Book

Translations are available in 日本語, Deutsche, Polszczyzna, Hrvatski, 简体中文, 繁体中文, 한국어

History about the Second Edition

Item 10: Prevent Repetition with Assignment Expressions

Sun 02 February 2020

An assignment expression—also known as the walrus operator—is a new syntax introduced in Python 3.8 to solve a long-standing problem with the language that can cause code duplication. Whereas normal assignment statements are written a = b and pronounced “a equals b”, these assignments are written a := b and pronounced “a walrus b” (because := looks like a pair of eyeballs and tusks). Continue reading »

Item 74: Consider memoryview and bytearray for Zero-Copy Interactions with bytes

Tue 22 October 2019

Though Python isn’t able to parallelize CPU-bound computation without extra effort (see Item 64: “Consider concurrent.futures for True Parallelism”), it is able to support high-throughput, parallel I/O in a variety of ways (see Item 53: “Use Threads for Blocking I/O, Avoid for Parallelism” and Item 60: “Achieve Highly Concurrent I/O with Coroutines” for details). That said, it’s surprisingly easy to use these I/O tools the wrong way and reach the conclusion that the language is too slow for even I/O-bound workloads. Continue reading »