Concepts: Collections¶
Short essays on the ideas behind the collections module. Read these once and keep coming back to them when you're deciding how to store something.
Essays in this section¶
- Why specialised containers — what
Counter,deque, and the rest buy you over a plaindictorlist: not just speed (thoughlist.pop(0)really is slow), but code that says what it means. - Choosing a container — a decision guide across the whole module and the built-ins:
Counterversus a manual count,defaultdictversussetdefault,dequeversuslist,namedtupleversusdictversus dataclass.