Lecture 11: Aliasing and Cloning
At a glance
- Price Free to watch, no sign-up
- Runtime 46 min
- Topics Computer Science
- Source MIT, Introduction to CS and Programming using Python
- Lecture Lecture 11 of 25
- Language English
MIT lecturer Ana Bell continues the 6.100L Introduction to CS and Programming using Python course with a session on how Python variables reference objects in memory. She works through aliasing, where two variable names point to the same list, and shows how mutating one changes the other unexpectedly. The lecture covers cloning techniques for making independent copies, list comprehensions as a concise way to build lists, and the distinction between shallow copies, which duplicate only the outer structure, and deep copies, which duplicate nested mutable elements as well. Bell works through code examples on screen, tracing variable references step by step to show where bugs commonly arise when programmers assume a copy was made but actually created an alias. The lecture runs 46 minutes and assumes familiarity with lists and functions from earlier sessions in the course.