Some discussion on when the envar should be evaluated.

This commit is contained in:
Barry Warsaw 2017-09-13 16:20:59 -07:00
parent e53582e975
commit 0a64b078b6
1 changed files with 23 additions and 0 deletions

View File

@ -141,6 +141,29 @@ implementation (e.g. PyCharm) that the hooks provided in this PEP will
be useful to them.
Evaluation of $PYTHONBREAKPOINT
-------------------------------
There has been some mailing list discussion around this topic. The basic
behavior as described above does not appear to be controversial. Guido has
expressed a preference for ``$PYTHONBREAKPOINT`` consultation happening in
the default implementation of ``sys.breakpointhook``.
The one point of discussion relates to whether the value of
``$PYTHONBREAKPOINT`` should be loaded on interpreter start, and whether its
value should be cached the first time it's accessed.
It is the PEP author's opinion that the environment variable need only be
looked up at the time of use. It is also the author's opinion that the value
of the environment variable can be accessed each time ``sys.breakpointhook``
is run, to allow for maximum functional flexibility. Because this feature
enters the debugger, any performance improvements for caching is negligible
and does not outweigh the flexibility. Further, because the special case of
``PYTHONBREAKPOINT=0`` is fast-tracked, the no-op code path is quite fast, and
should be in the noise given the function calls of ``breakpoint()`` ->
``sys.breakpointhook()``.
Breakpoint bytecode
-------------------