Debugging & Profiling

faulthandler — Dump the Python traceback

This module contains functions to dump Python tracebacks explicitly, on a fault, after a timeout, or on a user signal. Call faulthandler.enable() to install fault handlers for the SIGSEGV, SIGFPE, SIGABRT, SIGBUS, and SIGILL signals. You can also enable them at startup by setting the PYTHONFAULTHANDLER environment variable or by using the -X faulthandler command line option.

bdb — Debugger framework

Source code: Lib/bdb.py

Audit events table

This table contains all events raised by sys.audit() or PySys_Audit() calls throughout the CPython runtime and the standard library. These calls were added in 3.8.0 or later.

pdb — The Python Debugger

Source code: Lib/pdb.py

The Python Profilers

Source code: Lib/profile.py and Lib/pstats.py

trace — Trace or track Python statement execution

Source code: Lib/trace.py

tracemalloc — Trace memory allocations

Source code: Lib/tracemalloc.py

timeit — Measure execution time of small code snippets

Source code: Lib/timeit.py