Description
Feature or enhancement
Proposal:
Language implementations for the CPython runtime (Cython, JIT compilers, regular expression engines, template engines, etc.) need a way to signal PEP-669 monitoring events to the registered listeners.
-
We need a way to create events and inject them into the monitoring system. Since events have more than one signature, we might end up needing more than one C-API function for this.
-
We need a way to map 3D source code positions (file name, line, character) to 1D integer offsets. Code objects help, but branches might cross source file boundaries, so that's more tricky. For many use cases, a mapping between (line, character) positions and an integer offset would probably suffice, although templating languages usually provide some kind of include commands, as does Cython. There should be some help in the C-API for building up such a mapping.
The reason why I think we need CPython's help for mapping indices is that both sides, listeners and even producers, need to agree on the same mapping. Sadly, the events don't include line/character positions directly but only a single integer. So event producers need a way to produce a number that event listeners like coverage analysers can map back to a source code position.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/pep-669-low-impact-monitoring-for-cpython/13018/61?u=scoder
Linked PRs
- gh-111997: C-API for signalling monitoring events #116413
- gh-111997: Fix argument count for LINE event and clarify type of argument counts. #119179
- [3.13] gh-111997: Fix argument count for LINE event and clarify type of argument counts. (GH-119179) #119575
- gh-111997: update what's new in 3.13 re C API for monitoring events #123822
- [3.13] gh-111997: update what's new in 3.13 re C API for monitoring events (GH-123822) #123997
Metadata
Metadata
Assignees
Projects
Status