Python Tuples and Sets
Tuples and sets are often treated as secondary data structures behind lists and dicts, but they each solve specific problems that the other types cannot. Tuples provide immutable sequences for fixed data, function returns, and dict keys. Sets provide O(1) membership testing and mathematical set operations.
This collection covers both types, their guarantees, and the immutability concepts that connect them.
Tuples, Sets, and Immutability
4 articlesPython Tuples: Complete Guide
Tuple creation, indexing, unpacking, named tuples, and practical patterns for using tuples effectively.
Why Are Tuples Immutable?
The design reasoning behind tuple immutability, hashability, and why immutable types matter for dict keys and sets.
Why Can't I Index a Set in Python?
Why sets are unordered, how hash-based storage works, and alternatives when you need both uniqueness and ordering.
Python Immutability
What immutability means across all Python types, how it affects assignment and function arguments, and frozen collections.