Trey Hunner helps Python developers level-up their skills through corporate trainings and through self-paced Python learning with Python Morsels. Get in touch with Trey to improve your (or your team's) Python skills.
Variables and objects in Python: it's pointers all the way down
Trey Hunner
In Python, assignment statements don't copy objects, and data structures don't actually contain objects. These two surprising facts have a lot of interesting consequences and are the reason behind many of Python's design decisions.
In this talk, we'll explore the reference-like nature of Python's variables and objects, noting both the benefits and gotchas involved.
Among other ideas, we'll see that in Python:
- The word "change" is ambiguous
- Copying is usually explicit
- Tuples aren't always immutable
During the process, we'll consider our own mental model of Python.
In Python, it's pointers (or references, names, bindings, or aliases) all the way down.