We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Talks - Tian Gao: What makes a Python debugger possible and how can we make it 100x faster
Learn how Python debuggers work under the hood and explore the new sys.monitoring feature in Python 3.13 that promises 100x faster debugging performance compared to sys.settrace
-
Python debuggers like PDB traditionally cause ~100x slowdown due to triggering events for every line execution
-
sys.settrace
is the core mechanism behind Python debuggers, allowing callback functions to handle events like:- Function calls
- Line executions
- Returns
- Exceptions
-
Python 3.13 introduces
sys.monitoring
which provides:- Selective event enabling/disabling
- Function-level granularity control
- ~100x performance improvement when properly implemented
- Ability to only trigger necessary events
-
Frame objects provided by CPython contain crucial debugging information:
-
Local variables (
frame.f_locals
) - Call stack information
-
Line numbers (
frame.f_linenumber
) -
Code objects (
frame.f_code
)
-
Local variables (
-
Major debugging tool vendors are adopting the new
sys.monitoring
:- PyCharm’s PyDevD
- Microsoft’s VS Code debugging backend
- Coverage.py for performance improvements
-
Core debugger requirements include:
- Execution control (step into/over/out)
- Variable inspection
- Call stack examination
- Dynamic code execution (eval/exec)
-
The granularity problem of
sys.settrace
:- Can only enable/disable events globally
- Cannot selectively control events for specific functions
- Results in unnecessary event overhead