@@ -179,14 +179,9 @@ events, use the expression ``PY_RETURN | PY_START``.
179179Local events
180180''''''''''''
181181
182- Local events are associated with execution of a particular code object and
183- can all be disabled via :data: `DISABLE `. There are two kinds, which differ
184- in how :data: `DISABLE ` takes effect.
185-
186- **Instrumented local events ** require bytecode instrumentation and fire at
187- clearly defined instruction locations within a function. Returning
188- :data: `DISABLE ` from a callback disables the event at that specific
189- code location only, leaving all other locations unaffected:
182+ Local events are associated with normal execution of the program and happen
183+ at clearly defined locations. All local events can be disabled
184+ per location. The local events are:
190185
191186* :monitoring-event: `PY_START `
192187* :monitoring-event: `PY_RESUME `
@@ -200,24 +195,6 @@ code location only, leaving all other locations unaffected:
200195* :monitoring-event: `BRANCH_RIGHT `
201196* :monitoring-event: `STOP_ITERATION `
202197
203- **Non-instrumented local events ** do not require bytecode instrumentation and
204- are not tied to a specific instruction. They can fire at any point within
205- a function where the triggering condition occurs. Returning :data: `DISABLE `
206- from a callback disables the event for the entire code object (for the
207- current tool):
208-
209- * :monitoring-event: `PY_UNWIND `
210- * :monitoring-event: `EXCEPTION_HANDLED `
211- * :monitoring-event: `RAISE `
212- * :monitoring-event: `PY_THROW `
213- * :monitoring-event: `RERAISE `
214-
215- .. versionchanged :: 3.15
216- :monitoring-event: `PY_UNWIND `, :monitoring-event: `EXCEPTION_HANDLED `,
217- :monitoring-event: `RAISE `, :monitoring-event: `PY_THROW `, and
218- :monitoring-event: `RERAISE ` are now local events and can be disabled
219- via :data: `DISABLE `.
220-
221198Deprecated event
222199''''''''''''''''
223200
@@ -245,6 +222,28 @@ are controlled by the :monitoring-event:`CALL` event.
245222seen if the corresponding :monitoring-event: `CALL ` event is being monitored.
246223
247224
225+ .. _monitoring-event-global :
226+
227+ Other events
228+ ''''''''''''
229+
230+ Other events are not necessarily tied to a specific location in the
231+ program and cannot be individually disabled per location.
232+
233+ The other events that can be monitored are:
234+
235+ * :monitoring-event: `PY_THROW `
236+ * :monitoring-event: `PY_UNWIND `
237+ * :monitoring-event: `RAISE `
238+ * :monitoring-event: `EXCEPTION_HANDLED `
239+ * :monitoring-event: `RERAISE `
240+
241+ .. versionchanged :: 3.15
242+ Other events can now be turned on and disabled on a per code object
243+ basis. Returning :data: `DISABLE ` from a callback disables the event
244+ for the entire code object (for the current tool).
245+
246+
248247The STOP_ITERATION event
249248''''''''''''''''''''''''
250249
@@ -315,23 +314,21 @@ Disabling events
315314.. data :: DISABLE
316315
317316 A special value that can be returned from a callback function to disable
318- the event.
319-
320- All :ref: `local events <monitoring-event-local >` can be disabled by returning
321- :data: `sys.monitoring.DISABLE ` from a callback function. This does not change
322- which events are set globally.
317+ events for the current code location.
323318
324- For :ref: `instrumented local events <monitoring-event-local >`, :data: `DISABLE `
325- disables the event at the specific code location where it fired only, leaving
326- all other locations for the same event unaffected.
319+ :ref: `Local events <monitoring-event-local >` can be disabled for a specific code
320+ location by returning :data: `sys.monitoring.DISABLE ` from a callback function.
321+ This does not change which events are set, or any other code locations for the
322+ same event.
327323
328- For :ref: `non-instrumented local events <monitoring-event-local >`,
329- :data: `DISABLE ` disables the event for the entire code object (for the current
324+ :ref: `Other events <monitoring-event-global >` can be disabled on a per code
325+ object basis by returning :data: `sys.monitoring.DISABLE ` from a callback
326+ function. This disables the event for the entire code object (for the current
330327tool).
331328
332- Disabling events is very important for high performance monitoring. For
333- example, a program can be run under a debugger with no overhead if the
334- debugger disables all monitoring except for a few breakpoints.
329+ Disabling events for specific locations is very important for high performance
330+ monitoring. For example, a program can be run under a debugger with no overhead
331+ if the debugger disables all monitoring except for a few breakpoints.
335332
336333.. function :: restart_events() -> None
337334
0 commit comments