Allow limited PEP 523 plugins. (#2822)
This commit is contained in:
parent
5cf5c3baae
commit
43af7ba688
43
pep-0669.rst
43
pep-0669.rst
|
@ -291,42 +291,35 @@ Backwards Compatibility
|
||||||
|
|
||||||
This PEP is mostly backwards compatible.
|
This PEP is mostly backwards compatible.
|
||||||
|
|
||||||
This PEP is incompatible with :pep:`523` as the behavior would be undefined,
|
There are some compatibility issues with :pep:`523`, as the behavior
|
||||||
since the VM has no control over the behavior of :pep:`523` plugins.
|
of :pep:`523` plugins is outside of the VM's control.
|
||||||
|
It is up to :pep:`523` plugins to ensure that they respect the semantics
|
||||||
|
of this PEP. Simple plugins that do not change the state of the VM, and
|
||||||
|
defer execution to ``_PyEval_EvalFrameDefault()`` should continue to work.
|
||||||
|
|
||||||
Thus, if ``_PyInterpreterState_SetEvalFrameFunc()`` has been called and has
|
:func:`sys.settrace` and :func:`sys.setprofile` will act as if they were tools
|
||||||
changed the frame evaluation function, then calling
|
6 and 7 respectively, so can be used along side this PEP.
|
||||||
``sys.monitoring.set_events()``, ``sys.monitoring.set_local_events()``, or
|
|
||||||
``sys.monitoring.insert_marker`` will raise an exception.
|
|
||||||
|
|
||||||
Likewise, if ``sys.monitoring.set_events()``,
|
This means that :func:`sys.settrace` and :func:`sys.setprofile` may not work
|
||||||
``sys.monitoring.set_local_events()``, or ``sys.monitoring.insert_marker``
|
correctly with all :pep:`523` plugins. Although, simple :pep:`523`
|
||||||
has been called, then calling ``_PyInterpreterState_SetEvalFrameFunc()``
|
plugins, as described above, should be fine.
|
||||||
will raise an exception.
|
|
||||||
|
|
||||||
``sys.settrace`` and ``sys.setprofile`` will act as if they were tools 6 and 7
|
|
||||||
respectively, so can be used along side this PEP.
|
|
||||||
|
|
||||||
This makes ``sys.settrace`` and ``sys.setprofile`` incompatible with :pep:`523`.
|
|
||||||
Arguably, they already were as the author does not know of any PEP 523 plugin
|
|
||||||
that supports ``sys.settrace`` or ``sys.setprofile`` correctly.
|
|
||||||
This PEP merely formalizes that.
|
|
||||||
|
|
||||||
Performance
|
Performance
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
If no events are active, this PEP should have a small positive impact on
|
If no events are active, this PEP should have a small positive impact on
|
||||||
performance. Experiments show between 1 and 2% speedup from not supporting
|
performance. Experiments show between 1 and 2% speedup from not supporting
|
||||||
``sys.settrace()`` directly.
|
:func:`sys.settrace` directly.
|
||||||
|
|
||||||
The performance of ``sys.settrace()`` will be worse.
|
The performance of :func:`sys.settrace` will be worse.
|
||||||
The performance of ``sys.setprofile()`` should be better.
|
The performance of :func:`sys.setprofile` should be better.
|
||||||
However, tools relying on ``sys.settrace()`` and ``sys.setprofile()``
|
However, tools relying on :func:`sys.settrace` and
|
||||||
can be made a lot faster by using the API provided by this PEP.
|
:func:`sys.setprofile` can be made a lot faster by using the
|
||||||
|
API provided by this PEP.
|
||||||
|
|
||||||
If a small set of events are active, e.g. for a debugger, then the overhead
|
If a small set of events are active, e.g. for a debugger, then the overhead
|
||||||
of callbacks will be orders of magnitudes less than for ``sys.settrace`` and
|
of callbacks will be orders of magnitudes less than for :func:`sys.settrace`
|
||||||
much cheaper than using :pep:`523`.
|
and much cheaper than using :pep:`523`.
|
||||||
|
|
||||||
Coverage tools can be implemented at very low cost,
|
Coverage tools can be implemented at very low cost,
|
||||||
by returning ``DISABLE`` in all callbacks.
|
by returning ``DISABLE`` in all callbacks.
|
||||||
|
|
Loading…
Reference in New Issue