Skip to content

🧠 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