Specialize Your Own Collection in Python
Mapping, Sequence or Collection in Python: you choose the best one for the data structure you want to build. A simple explanation of everything you need.
Code
Inside articles there are more settings: width, font size, series position and code.
Saved in this browser.
Mapping, Sequence or Collection in Python: you choose the best one for the data structure you want to build. A simple explanation of everything you need.
keys(), values() and items() return views, not lists: they stay in sync with the dictionary, key views behave like sets, and you can turn them into lists.
What makes a Python object hashable, why lists aren't, how hash(), __hash__ and __eq__ work together, and how to make your own class hashable.
Learn whether a variable can change (mutable) or not (immutable). Mutable: List, Dict, Set. Immutable: String, Int, Float, Bool, Tuple, Range, Decimal.
Learn how to build your own Collection in Python step by step: Container, Sized and Iterable explained, plus the difference between an Iterator and an Iterable.
Learn how to build a data stream by balancing memory use and processing time: buffer data for a steady flow, generate data on demand, and cache results.