π§ Module 11: Memory & Performance¶
Writing correct programs is step one. Writing programs that are fast enough and use memory efficiently is step two.
This module teaches the practical side of performance:
- how Python stores objects in memory,
- what βreferencesβ actually mean,
- how to reason about time/space complexity,
- and how to apply safe, measurable optimizations.
Estimated Time: 8-10 hours \ Prerequisites: Module 02 (Data Structures), Module 03 (Algorithms) \ Level: βββ Intermediate
π Topics Covered¶
| # | Topic | Description | Key Concepts |
|---|---|---|---|
| 01 | Memory Basics | How Python represents objects | id(), mutability, GC, memoryview |
| 02 | References vs Values | Aliasing and copying | shallow vs deep copy, copy module |
| 03 | Time Complexity | Reason about runtime growth | linear vs quadratic, sets vs lists |
| 04 | Space Complexity | Reason about memory usage | in-place, recursion stack, generators |
| 05 | Big-O Notation | Analyze algorithms consistently | common Big-O classes, tradeoffs |
| 06 | Optimization Techniques | Make code faster safely | profiling, caching, built-ins |
π― Learning Goals¶
By the end of this module, you should be able to:
- Explain how Python uses object references and why βassignment doesnβt copyβ.
- Predict how runtime changes when input size grows (Big-O).
- Choose data structures with appropriate performance characteristics.
- Identify βslowβ patterns (nested loops, repeated work, unnecessary copies).
- Apply optimizations only after measuring.
π Module Structure¶
11_memory_performance/
βββ README.md
βββ 01_memory_basics/
β βββ README.md
β βββ examples.py
β βββ exercises.py
β βββ quiz.md
βββ 02_references_vs_values/
β βββ README.md
β βββ examples.py
β βββ exercises.py
β βββ quiz.md
βββ 03_time_complexity/
β βββ README.md
β βββ examples.py
β βββ exercises.py
β βββ quiz.md
βββ 04_space_complexity/
β βββ README.md
β βββ examples.py
β βββ exercises.py
β βββ quiz.md
βββ 05_big_o_notation/
β βββ README.md
β βββ examples.py
β βββ exercises.py
β βββ quiz.md
βββ 06_optimization_techniques/
βββ README.md
βββ examples.py
βββ exercises.py
βββ quiz.md
Start here: 01_memory_basics