Python Programming

Mutation, Aliasing, and the Python Memory Model

3:31

Plays from YouTube. Watch on YouTube

Why can changing one Python list unexpectedly change another variable?

Meet object identity, mutability and aliasing through concrete memory traces.

We start by separating names and objects, then compare reassignment with in-place list mutation.

From there, we examine aliasing, equality versus identity, shallow copies and how function arguments bind to caller-owned objects.

Finally, we debug mutable default arguments and learn how to test side effects explicitly.

The big idea: Python names point to objects; understanding what is shared explains what changes.

The Python memory model explained visually, one concept at a time.