Debugging and profiling techniques

Summary

[EuroPython 2011] Giovanni Bajo - 22 June 2011 in "Track Spaghetti"

Description

This talk will give on overview over some common problems related to profiling and debugging CPython applications (especially desktop-based ones).

The following subjects will be covered:

  • Debugging of memory/resource leaks (circular references, del, weakref, garbage collector, etc.). We will show in details how the memory management of Python objects work and we will show a few tricks to track memory leaks
  • Python code profiling (profile/hotshots/cProfile, design of small tests, etc.). We will show how to measure, profile, and analyse an application to spot performance problems and solve them.
  • Post-mortem step-by-step debugging of C/C++ extension under Windows. We will show how to setup Visual Studio for debugging, how to see a traceback in case of an unexpected segfault, and how to further debug and solve the crash.

This talk is aimed at intermediate Python programmers, who have already developed non-trivial Python applications but have never "jumped through" the interpreter abstraction layer. If you feel a little lost when you see a segfault from a Python program or you don't have a clear idea how memory is collected in Python, this talk is perfect for you.