Mutable vs Immutable
Mutable vs Immutable — Mutable objects can be changed after creation (list, dict, set), while immutable objects cannot (str, int, tuple, frozenset). Understanding mutability is crucial in Python. Immutable types guarantee that their value never changes, making them hashable and safe as dictionary keys. Mutable types can be modified in-place but are not hashable. Assignment (`=`) never copies data — it creates a new reference. Use `copy()` or `deepcopy()` for actual copies. This term relates to the Built-in Functions category of the reference. You will meet mutable vs immutable in practice when working with APIs such as print(), len(), range(), type(). Related terms: Decorator, Generator, Context Manager, GIL (Global Interpreter Lock), Duck Typing, List Comprehension. Understanding mutable vs immutable makes the rest of the Python documentation noticeably easier to follow, because the concept recurs across function references, guides, snippets, and error messages you will meet in real projects.