python / cpython

The Python programming language
https://www.python.org
Other
63.34k stars 30.32k forks source link

Should we add runnable example for `sys.monitoring`? #125770

Open xuantengh opened 1 week ago

xuantengh commented 1 week ago

Currently the sys.monitoring doc (https://docs.python.org/3/library/sys.monitoring.html) contains NO concrete example of how sys.monitoring APIs should be invoked in a workflow. Nor did I find any straightforward examples of sys.monitoring after some simple Googling.

Should we consider adding an runnable example like function coverage with sys.monitoring APIs?

AA-Turner commented 1 week ago

E.g. https://mostlynerdless.de/blog/2023/11/10/lets-create-a-python-debugger-together-part-4-python-3-12-edition/?

A

xuantengh commented 1 week ago

E.g. https://mostlynerdless.de/blog/2023/11/10/lets-create-a-python-debugger-together-part-4-python-3-12-edition/?

IMHO this is still somehow complicated. I think the code snippet in #111963 may be a good example?

gaogaotiantian commented 1 week ago

I'm a bit on the fence. On one hand, it would be nice to have some example. However, this is an API that is almost exclusively for dev tool developers and I don't know how much examples would benefit, compared to the extra space it would take to make the docs less readable. As a comparison, sys.settrace and sys.setprofile does not have any examples in the docs (that I can find).

The reason why there aren't many examples on the internet is because the feature is only out about a year. Even stdlib has not fully adopted it yet.