Skip to content

Course

Python Performance & Optimization

A practitioner's path from honest measurement to targeted optimization: profiling, memory, vectorization, concurrency, native extensions, and free-threaded Python.

9 lessons

Course Q&A

Reviews

Enrolled members can rate this course.

No reviews yet.

Measure Before You Touch Anything

Profiling, benchmarking, and memory measurement that lead you to the real bottleneck instead of the interesting one.

  1. 01Profile First: cProfile, pstats, and Sampling ProfilersOptimization without a profile is guessing with extra confidence. Learn what cProfile actually measures, how to read it, and when a sampling profiler is the safer instrument.24mOpen
  2. 02Benchmarks That Survive ReviewMicrobenchmarks lie in predictable ways: warmup, allocator noise, timing granularity, and dead-code elimination. Build measurements you would trust in an incident review.21mOpen
  3. 03Memory Profiling: Where the Bytes Actually LiveRSS is not object size, leaks are usually caches, and Python's allocator makes small objects stranger than they look. Measure memory growth before rewriting anything.23mOpen

Make Python Faster Without Leaving Python

Algorithmic fixes, interpreter-aware code, vectorization, and choosing the right concurrency model.

  1. 01Algorithmic and Interpreter-Aware WinsThe fastest Python is usually less work, not cleverer work: better complexity, fewer object allocations, and using builtins whose loops live in C.20mOpen
  2. 02Vectorization with NumPy: Move the Loop Out of PythonNumPy's speed comes from contiguous typed memory and loops implemented in C. Learn the layouts, dtype choices, and pandas traps that decide whether vectorization works.25mOpen
  3. 03Threading, Multiprocessing, and asyncio: Pick by Waiting or WorkingThe GIL decision tree: threads and asyncio for I/O-bound waiting, processes or native extensions for CPU-bound work, and the hidden costs of each.26mOpen

Native Speed and the Post-GIL Frontier

Cython and Rust extensions, plus what free-threaded Python changes and what it does not.

  1. 01Cython: Keep Python's Shape, Drop the Hot Loop into CWhen a measured hot loop cannot vectorize, Cython can compile typed Python-like code into C. The wins come from types, memoryviews, and knowing what still crosses back into Python.25mOpen
  2. 02Rust Extensions with PyO3: Native Speed Without C's FootgunsPyO3 and maturin let you move measured kernels into Rust with safe memory management, strong typing, and wheels your Python application can deploy normally.27mOpen
  3. 03Free-Threaded Python: What Changes When the GIL Steps BackPython's experimental free-threaded build removes the global interpreter lock, but not the need for ownership, synchronization, or benchmarks. Learn what to test before betting a service on it.24mOpen