Skip to main content
Loading page…
Python Mastery
Chapter 13
Lesson 2 of 4
Mutability, Hashability & Shared State
Contents
Notes
Tutor
Concept
Mutable vs Immutable — The Deep Model
Loading activity…
Previous
1 / 9
Continue
Contents
Notes
Discussion
Tutor
30 min
9 activities
0 of 9 done
In this lesson
1
Mutable vs Immutable — The Deep Model
2
The Mutable Default Argument Trap (Memory-Model Angle)
3
Shared-Reference Bugs in Practice
4
Hashability: The Key to Dicts and Sets
5
Fix the Mutable Default Argument
6
Classify: Mutable or Immutable?
7
Hashability Inspector
8
Tuple-with-List Gotcha
9
Why Must Dict Keys Be Hashable?
Objectives
Predict exactly which operations mutate an object vs create a new one
Diagnose and fix the mutable-default-argument bug
Explain hashability and why dict keys and set members must be hashable
Identify the tuple-containing-list gotcha and reason about its implications
Chapter 13 · The Python Data Model & Memory
Objects, Identity & References
Mutability, Hashability & Shared State
Copying: Shallow vs Deep
Memory, Reference Counting & __slots__
Previous: Objects, Identity & References
Next: Copying: Shallow vs Deep