PEP 669: Require names for tools. (GH-2770)

* Add Petr's suggestion for naming tools.

* Clarify that instrumentation works similarly to PEP 659, but that PEP 659 is not a requirement.
This commit is contained in:
Mark Shannon 2022-08-24 11:10:28 +01:00 committed by GitHub
parent 4f34145396
commit 62f1b67db4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -105,10 +105,13 @@ Identifiers are integers in the range 0 to 5.
::
sys.monitoring.use_tool_id(id)->None
sys.monitoring.free_tool_id(id)->None
sys.monitoring.use_tool_id(id, name:str) -> None
sys.monitoring.free_tool_id(id) -> None
sys.monitoring.get_tool(id) -> str | None
``sys.monitoring.use_tool_id`` raises a ``ValueError`` if ``id`` is in use.
``sys.monitoring.get_tool`` returns the name of the tool if ``id`` is in use,
otherwise it returns ``None``.
All IDs are treated the same by the VM with regard to events, but the following
IDs are pre-defined to make co-operation of tools easier::
@ -342,6 +345,7 @@ In general these operations can be considered to be fast:
* ``def get_events(tool_id: int)->Event``
* ``def get_local_events(tool_id: int, code: CodeType)->Event``
* ``def register_callback(tool_id: int, event: Event, func: Callable)->Optional[Callable]``
* ``def get_tool(tool_id) -> str | None``
These operations are slower, but not especially so:
@ -351,7 +355,7 @@ These operations are slower, but not especially so:
And these operations should be regarded as slow:
* ``def use_tool_id(id)->None``
* ``def use_tool_id(id, name:str)->None``
* ``def free_tool_id(id)->None``
* ``def set_events(tool_id: int, event_set: Event)->None``
* ``def restart_events()->None``
@ -396,9 +400,9 @@ implementation for later versions of CPython and other Python implementations
may differ considerably.
The proposed implementation of this PEP will be built on top of the quickening
step of :pep:`PEP 659 <659#quickening>`.
Activating some events will cause all code objects to
be quickened before they are executed.
step of CPython 3.11, as described in :pep:`PEP 659 <659#quickening>`.
Instrumentation works in much the same way as quickening, bytecodes are
replaced with instrumented ones as needed.
For example, if the ``C_CALL`` event is turned on,
then all call instructions will be