6
Picking the Right Data Structure
This chapter hopes to save its readers from unnecessarily difficult code by drawing attention to a number of useful data structures that Python beginners, and even many advanced language users, may be unaware of or merely tend to forget. Four of these data structures are contained in the Python standard library, in collections
, and another is in dataclasses
(sort of—we’ll discuss that). The last mistake discussed looks at several additional, closely related, sequence (i.e., list
-like) data structures that can sometimes be more efficient than lists. These are all built-ins or in standard library modules.
This book’s longest discussion of mistakes comes in Chapter 7, Misusing Data Structures, in the section “ ...
Get Better Python Code: A Guide for Aspiring Experts now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.