8000 PEP 558: fix footnote references (#2754) · python/peps@a4329d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit a4329d4

Browse files
authored
PEP 558: fix footnote references (#2754)
* PEP 558: fix footnote references * PEP 558: Remove orphaned footnote * PEP 558: Remove redundant emacs metadata * PEP 558: Fix code formatting * PEP 558: Fix typos * PEP 558: Update BPO redirects * PEP 558: Convert to regular links
1 parent cdc1a44 commit a4329d4

File tree

1 file changed

+56
-52
lines changed

1 file changed

+56
-52
lines changed

pep-0558.rst

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ behaviour at function scope to make it more predictable and independent of the
2424
presence or absence of tracing functions.
2525

2626
In addition, it proposes that the following functions be added to the stable
27-
Python C API/ABI::
27+
Python C API/ABI:
28+
29+
.. code-block:: c
2830
2931
typedef enum {
3032
PyLocals_UNDEFINED = -1,
@@ -145,7 +147,7 @@ builtin to read as follows:
145147
dictionaries.
146148

147149

148-
There would also be a versionchanged note for the release making this change:
150+
There would also be a ``versionchanged`` note for the release making this change:
149151

150152
In prior versions, the semantics of mutating the mapping object returned
151153
from ``locals()`` were formally undefined. In CPython specifically,
@@ -273,14 +275,20 @@ Summary of proposed implementation-specific changes
273275

274276
* Changes are made as necessary to provide the updated Python level semantics
275277
* Two new functions are added to the stable ABI to replicate the updated
276-
behaviour of the Python ``locals()`` builtin::
278+
behaviour of the Python ``locals()`` builtin:
279+
280+
.. code-block:: c
277281
278282
PyObject * PyLocals_Get();
279283
PyLocals_Kind PyLocals_GetKind();
284+
280285
* One new function is added to the stable ABI to efficiently get a snapshot of
281-
the local namespace in the running frame::
286+
the local namespace in the running frame:
287+
288+
.. code-block:: c
282289
283290
PyObject * PyLocals_GetCopy();
291+
284292
* Corresponding frame accessor functions for these new public APIs are added to
285293
the CPython frame C API
286294
* On optimised frames, the Python level ``f_locals`` API will return dynamically
@@ -494,7 +502,9 @@ independent, behaviour. However, it is also desirable to allow C code to
494502
exactly mimic the behaviour of Python code at the same scope.
495503

496504
To enable mimicking the behaviour of Python code, the stable C ABI would gain
497-
the following new functions::
505+
the following new functions:
506+
507+
.. code-block:: c
498508
499509
PyObject * PyLocals_Get();
500510
PyLocals_Kind PyLocals_GetKind();
@@ -526,15 +536,19 @@ information visually through lexical scoping (as covered in the new ``locals()``
526536
builtin documentation).
527537

528538
To allow extension module code to behave consistently regardless of the active
529-
Python scope, the stable C ABI would gain the following new function::
539+
Python scope, the stable C ABI would gain the following new function:
540+
541+
.. code-block:: c
530542
531543
PyObject * PyLocals_GetCopy();
532544
533545
``PyLocals_GetCopy()`` returns a new dict instance populated from the current
534546
locals namespace. Roughly equivalent to ``dict(locals())`` in Python code, but
535547
avoids the double-copy in the case where ``locals()`` already returns a shallow
536548
copy. Akin to the following code, but doesn't assume there will only ever be
537-
two kinds of locals result::
549+
two kinds of locals result:
550+
551+
.. code-block:: c
538552
539553
locals = PyLocals_Get();
540554
if (PyLocals_GetKind() == PyLocals_DIRECT_REFERENCE) {
@@ -598,7 +612,9 @@ specifics of when the namespace it returns gets refreshed are still an
598612
interpreter implementation detail)
599613

600614
The additions to the public CPython C API are the frame level enhancements
601-
needed to support the stable C API/ABI updates::
615+
needed to support the stable C API/ABI updates:
616+
617+
.. code-block:: c
602618
603619
PyLocals_Kind PyFrame_GetLocalsKind(frame);
604620
PyObject * PyFrame_GetLocals(frame);
@@ -628,7 +644,9 @@ affected code should be updated to use
628644
instead.
629645

630646
In addition to the above documented interfaces, the draft reference
631-
implementation also exposes the following undocumented interfaces::
647+
implementation also exposes the following undocumented interfaces:
648+
649+
.. code-block:: c
632650
633651
PyTypeObject _PyFastLocalsProxy_Type;
634652
#define _PyFastLocalsProxy_CheckExact(self) Py_IS_TYPE(op, &_PyFastLocalsProxy_Type)
@@ -1016,7 +1034,7 @@ specifically related to the C API:
10161034
* :pep:`667` still proposes completely unnecessary C API breakage (the programmatic
10171035
deprecation and eventual removal of ``PyEval_GetLocals()``,
10181036
``PyFrame_FastToLocalsWithError()``, and ``PyFrame_FastToLocals()``) without
1019-
justification, when it is entirely possible to keep these working indefintely
1037+
justification, when it is entirely possible to keep these working indefinitely
10201038
(and interoperably) given a suitably designed fast locals proxy implementation
10211039
* the fast locals proxy handling of additional variables is defined in this PEP
10221040
in a way that is fully interoperable with the existing ``PyEval_GetLocals()``
@@ -1029,7 +1047,7 @@ specifically related to the C API:
10291047
like a type name than a data access API.
10301048
* this PEP adds ``PyLocals_GetCopy()`` and ``PyFrame_GetLocalsCopy()`` APIs to
10311049
allow extension modules to easily avoid incurring a double copy operation in
1032-
frames where ``PyLocals_Get()`` alreadys makes a copy
1050+
frames where ``PyLocals_Get()`` already makes a copy
10331051
* this PEP adds ``PyLocals_Kind``, ``PyLocals_GetKind()``, and
10341052
``PyFrame_GetLocalsKind()`` to allow extension modules to identify when code
10351053
is running at function scope without having to inspect non-portable frame and
@@ -1238,7 +1256,7 @@ complexity improvement.
12381256
The O(1) nature of the other operations can be restored by adding implementation
12391257
code that doesn't rely on the value cache being up to date.
12401258

1241-
Keeping the iterator/iterable retrieval methods as ``O(1)`` will involve
1259+
Keeping the iterator/iterable retrieval methods as O(1) will involve
12421260
writing custom replacements for the corresponding builtin dict helper types,
12431261
just as proposed in :pep:`667`. As illustrated above, the implementations would
12441262
be similar to the pseudo-code presented in :pep:`667`, but not identical (due to
@@ -1274,7 +1292,7 @@ Thanks to Nathaniel J. Smith for proposing the write-through proxy idea in
12741292
PEP that attempted to avoid introducing such a proxy.
12751293

12761294
Thanks to Steve Dower and Petr Viktorin for asking that more attention be paid
1277-
to the developer experience of the proposed C API additions [8,13]_.
1295+
to the developer experience of the proposed C API additions [8]_ [13]_.
12781296

12791297
Thanks to Larry Hastings for the suggestion on how to use enums in the stable
12801298
ABI while ensuring that they safely support typecasting from arbitrary
@@ -1283,7 +1301,7 @@ integers.
12831301
Thanks to Mark Shannon for pushing for further simplification of the C level
12841302
API and semantics, as well as significant clarification of the PEP text (and for
12851303
restarting discussion on the PEP in early 2021 after a further year of
1286-
inactivity) [10,11,12]_. Mark's comments that were ultimately published as
1304+
inactivity) [10]_ [11]_ [12]_. Mark's comments that were ultimately published as
12871305
:pep:`667` also directly resulted in several implementation efficiency improvements
12881306
that avoid incurring the cost of redundant O(n) mapping refresh operations
12891307
when the relevant mappings aren't used, as well as the change to ensure that
@@ -1293,58 +1311,44 @@ the state reported through the Python level ``f_locals`` API is never stale.
12931311
References
12941312
==========
12951313

1296-
.. [1] Broken local variable assignment given threads + trace hook + closure
1297-
(https://bugs.python.org/issue30744)
1314+
.. [1] `Broken local variable assignment given threads + trace hook + closure
1315+
<https://github.com/python/cpython/issues/74929>`_
12981316
1299-
.. [2] Clarify the required behaviour of ``locals()``
1300-
(https://bugs.python.org/issue17960)
1317+
.. [3] `Updating function local variables from pdb is unreliable
1318+
<https://github.com/python/cpython/issues/5384)>`_
13011319
1302-
.. [3] Updating function local variables from pdb is unreliable
1303-
(https://bugs.python.org/issue9633)
1320+
.. [4] `CPython's Python API for installing trace hooks
1321+
<https://docs.python.org/dev/library/sys.html#sys.settrace>`_
13041322
1305-
.. [4] CPython's Python API for installing trace hooks
1306-
(https://docs.python.org/dev/library/sys.html#sys.settrace)
1323+
.. [5] `CPython's C API for installing trace hooks
1324+
<https://docs.python.org/3/c-api/init.html#c.PyEval_SetTrace>`_
13071325
1308-
.. [5] CPython's C API for installing trace hooks
1309-
(https://docs.python.org/3/c-api/init.html#c.PyEval_SetTrace)
1326+
.. [6] `PEP 558 reference implementation
1327+
<https://github.com/python/cpython/pull/3640/files>`_
13101328
1311-
.. [6] PEP 558 reference implementation
1312-
(https://github.com/python/cpython/pull/3640/files)
1329+
.. [7] `Nathaniel's review of possible function level semantics for locals()
1330+
<https://mail.python.org/pipermail/python-dev/2019-May/157738.html>`_
13131331
1314-
.. [7] Nathaniel's review of possible function level semantics for locals()
1315-
(https://mail.python.org/pipermail/python-dev/2019-May/157738.html)
1332+
.. [8] `Discussion of more intentionally designed C API enhancements
1333+
<https://discuss.python.org/t/pep-558-defined-semantics-for-locals/2936/3>`_
13161334
1317-
.. [8] Discussion of more intentionally designed C API enhancements
1318-
(https://discuss.python.org/t/pep-558-defined-semantics-for-locals/2936/3)
1335+
.. [9] `Disable automatic update of frame locals during tracing
1336+
<https://github.com/python/cpython/issues/86363>`_
13191337
1320-
.. [9] Disable automatic update of frame locals during tracing
1321-
(https://bugs.python.org/issue42197)
1338+
.. [10] `python-dev thread: Resurrecting PEP 558 (Defined semantics for locals())
1339+
<https://mail.python.org/archives/list/python-dev@python.org/thread/TUQOEWQSCQZPUDV2UFFKQ3C3I4WGFPAJ/>`_
13221340
1323-
.. [10] python-dev thread: Resurrecting PEP 558 (Defined semantics for locals())
1324-
(https://mail.python.org/archives/list/python-dev@python.org/thread/TUQOEWQSCQZPUDV2UFFKQ3C3I4WGFPAJ/)
1341+
.. [11] `python-dev thread: Comments on PEP 558
1342+
<https://mail.python.org/archives/list/python-dev@python.org/thread/A3UN4DGBCOB45STE6AQBITJFW6UZE43O/>`_
13251343
1326-
.. [11] python-dev thread: Comments on PEP 558
1327-
(https://mail.python.org/archives/list/python-dev@python.org/thread/A3UN4DGBCOB45STE6AQBITJFW6UZE43O/)
1344+
.. [12] `python-dev thread: More comments on PEP 558
1345+
<https://mail.python.org/archives/list/python-dev@python.org/thread/7TKPMD5LHCBXGFUIMKDAUZELRH6EX76S/>`_
13281346
1329-
.. [12] python-dev thread: More comments on PEP 558
1330-
(https://mail.python.org/archives/list/python-dev@python.org/thread/7TKPMD5LHCBXGFUIMKDAUZELRH6EX76S/)
1331-
1332-
.. [13] Petr Viktorin's suggestion to use an enum for ``PyLocals_Get``'s behaviour
1333-
(https://mail.python.org/archives/list/python-dev@python.org/message/BTQUBHIVE766RPIWLORC5ZYRCRC4CEBL/)
1347+
.. [13] `Petr Viktorin's suggestion to use an enum for PyLocals_Get's behaviour
1348+
<https://mail.python.org/archives/list/python-dev@python.org/message/BTQUBHIVE766RPIWLORC5ZYRCRC4CEBL/>`_
13341349
13351350
Copyright
13361351
=========
13371352

13381353
This document is placed in the public domain or under the
13391354
CC0-1.0-Universal license, whichever is more permissive.
1340-
1341-
1342-
1343-
..
1344-
Local Variables:
1345-
mode: indented-text
1346-
indent-tabs-mode: nil
1347-
sentence-end-double-space: t
1348-
fill-column: 70
1349-
coding: utf-8
1350-
End:

0 commit comments

Comments
 (0)
0