Skip to content

Commit 1b8bb3c

Browse files
committed
Document new events
1 parent 9318ce1 commit 1b8bb3c

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

Doc/library/sys.monitoring.rst

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,17 @@ Events
7979

8080
The following events are supported:
8181

82-
.. monitoring-event:: BRANCH
82+
.. monitoring-event:: BRANCH_LEFT
8383

84-
A conditional branch is taken (or not).
84+
A conditional branch goes left.
85+
86+
It is up to the tool to determine how to present "left" and "right" branches.
87+
There is no guarantee which branch is "left" and which is "right", except
88+
that it will be consistent for the duration of the program.
89+
90+
.. monitoring-event:: BRANCH_RIGHT
91+
92+
A conditional branch goes right.
8593

8694
.. monitoring-event:: CALL
8795

@@ -180,9 +188,20 @@ The local events are:
180188
* :monitoring-event:`LINE`
181189
* :monitoring-event:`INSTRUCTION`
182190
* :monitoring-event:`JUMP`
183-
* :monitoring-event:`BRANCH`
191+
* :monitoring-event:`BRANCH_LEFT`
192+
* :monitoring-event:`BRANCH_RIGHT`
184193
* :monitoring-event:`STOP_ITERATION`
185194

195+
Deprecated event
196+
''''''''''''''''
197+
198+
* :monitoring-event:`BRANCH`
199+
200+
The :monitoring-event:`BRANCH` event is deprecated in 3.14.
201+
Using :monitoring-event:`BRANCH_LEFT` and :monitoring-event:`BRANCH_RIGHT`
202+
events will give much better performance as they can be disabled
203+
independently.
204+
186205
Ancillary events
187206
''''''''''''''''
188207

@@ -357,13 +376,11 @@ Different events will provide the callback function with different arguments, as
357376

358377
func(code: CodeType, line_number: int) -> DISABLE | Any
359378

360-
* :monitoring-event:`BRANCH` and :monitoring-event:`JUMP`::
379+
* :monitoring-event:`BRANCH_LEFT`, :monitoring-event:`BRANCH_RIGHT` and :monitoring-event:`JUMP`::
361380

362381
func(code: CodeType, instruction_offset: int, destination_offset: int) -> DISABLE | Any
363382

364383
Note that the *destination_offset* is where the code will next execute.
365-
For an untaken branch this will be the offset of the instruction following
366-
the branch.
367384

368385
* :monitoring-event:`INSTRUCTION`::
369386

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Adds two new local events to sys.monitoring, ``BRANCH_LEFT`` and
2+
``BRANCH_RIGHT``. This allows the two arms of the branch to be disabled
3+
independently, which should hugely improve performance of branch-level
4+
coverage tools. The old branch event, ``BRANCH`` is now deprecated.

0 commit comments

Comments
 (0)