Skip to main content
Loading page…
Python Mastery
Chapter 25
Lesson 4 of 4
Profiling & Performance
Contents
Notes
Tutor
Concept
The Golden Rule: Measure First
Loading activity…
Previous
1 / 9
Continue
Contents
Notes
Discussion
Tutor
27 min
9 activities
0 of 9 done
In this lesson
1
The Golden Rule: Measure First
2
timeit: Benchmarking Snippets
3
cProfile: Finding the Bottleneck
4
Big-O and Data-Structure Choices
5
Common Python Speedups
6
Check: Big-O Complexity
7
Tip: When Fast Enough Is Enough
8
Practice: Optimise a Slow Function
9
Module Checkpoint: Testing, Debugging & Performance
Objectives
Measure code speed accurately using timeit and cProfile
Apply the 'measure first' rule to avoid premature optimization
Identify and apply common Python speedups: sets, comprehensions, generators, and avoiding repeated work
Reason about algorithmic complexity (big-O) to make better data-structure choices
Chapter 25 · Testing, Debugging & Performance
Testing with pytest
unittest & Mocking
Debugging Effectively
Profiling & Performance
Previous: Debugging Effectively
Next: Property-Based Testing with Hypothesis