pudb icon indicating copy to clipboard operation
pudb copied to clipboard

Support for `sys.monitoring` backend?

Open wshanks opened this issue 7 months ago • 1 comments

Is your feature request related to a problem? Please describe. Python 3.12 added a new namespace sys.monitoring (PEP669) that allows tracing Python code with lower overhead than previous methods. Numbers I have seen range between a 10x to 100x speed up of code running in between break points. It would be great if pudb could make use of this.

Describe the solution you'd like Recently, in Python 3.14 (still in alpha), the Bdb class was updated to support a backend='monitoring' option. Pudb mostly relies on Bdb (I think), so perhaps it could add a preference for making use of this new backend starting with Python 3.14.

Describe alternatives you've considered None

Additional context I haven't looked closely at Pudb's interface to Bdb. A quick search shows one call to sys.settrace. That might work around the Bdb interface which supports sys.settrace and sys.monitoring backends and need to be modified for the sys.monitoring case. Also, there could be other things in the Pudb code that make it impractical to use the monitoring backend. I haven't looked into this thoroughly enough so far. For now, I wanted to raise awareness about the potential performance improvement.

wshanks avatar May 09 '25 17:05 wshanks

Ooh interesting. Thanks for pointing that out. I might play around some over the summer if/when I have some time. Thanks to uv, it's not hard to do:

uvx --python 3.14 pudb debug_me.py

The good news is that at, at least off the bat, pudb (using settrace) still works without a problem.

inducer avatar May 09 '25 18:05 inducer