Introduction to Profiling Python Code - OCFP3

OCF

This course provides a practical introduction to profiling and performance analysis of Python code. It is designed for Python users who want to identify bottlenecks, optimise runtime, and better understand how their code behaves under different workloads. Participants will learn how to use profiling tools to gain insights into function call frequency, execution time, and memory usage.

Contents
The course includes the following topics:

  • The need for profiling: performance vs. readability trade-offs
  • Built-in profiling tools: time, timeit, and cProfile
  • Line-by-line profiling with line profiler
  • Memory profiling with memory profiler and tracemalloc
  • Best practices for writing performance-aware Python code

Format
The course is structured around live coding demonstrations and guided hands-on exercises. Each topic includes simple, real-world code examples designed to illustrate key profiling concepts.

Duration
This course is designed to be completed in approximately half a day (around 3 to 4 hours).

Prerequisites
• OCFP2