Part 1 · Section 03

Variables and Memory

In many languages a variable is a named box that holds a value. Python works differently: a variable is a name that refers to an object living somewhere in memory. That one idea explains a lot of behavior that otherwise looks surprising, like why changing one list can change “another”, why is and == can disagree, and why a is b is sometimes True for numbers you never linked together.

In this section you’ll learn:

Lectures

  1. 01Variables are Memory References✓
  2. 02Reference Counting✓
  3. 03Garbage Collection✓
  4. 04Dynamic vs Static Typing✓
  5. 05Variable Re-Assignment✓
  6. 06Object Mutability✓
  7. 07Function Arguments and Mutability✓
  8. 08Shared References and Mutability✓
  9. 09Variable Equality✓
  10. 10Everything is an Object✓
  11. 11Python Optimizations - Interning✓
  12. 12Python Optimizations - String Interning✓
  13. 13Python Optimizations - Peephole✓

Practice: quiz & exercises

12 quiz questions · 3 coding exercises

Go to practice →