Skip to content

Commit 3b52323

Browse files
authored
PEP 757: Cleanup (#3979)
* endian => endianness * Move text to function documentations * Discussions: add link to the PEP discussion
1 parent 659cfe5 commit 3b52323

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

peps/pep-0757.rst

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Data needed by `GMP <https://gmplib.org/>`_-like import-export functions.
7575
- ``1`` for most significant digit first
7676
- ``-1`` for least significant digit first
7777

78-
.. c:member:: int8_t endian
78+
.. c:member:: int8_t endianness
7979
8080
Digit endianness:
8181

@@ -89,11 +89,10 @@ Data needed by `GMP <https://gmplib.org/>`_-like import-export functions.
8989
9090
See the :c:struct:`PyLongLayout` structure.
9191
92-
93-
The function must not be called before Python initialization nor after
94-
Python finalization. The returned layout is valid until Python is
95-
finalized. The layout is the same for all Python sub-interpreters and
96-
so it can be cached.
92+
The function must not be called before Python initialization nor after
93+
Python finalization. The returned layout is valid until Python is
94+
finalized. The layout is the same for all Python sub-interpreters and
95+
so it can be cached.
9796
9897
9998
Export API
@@ -141,16 +140,16 @@ Export API
141140
This function always succeeds if *obj* is a Python :class:`int` object or a
142141
subclass.
143142
144-
If *export_long.digits* is not ``NULL``, :c:func:`PyLong_FreeExport` must be
143+
If *export_long->digits* is not ``NULL``, :c:func:`PyLong_FreeExport` must be
145144
called when the export is no longer needed.
146145
147-
On CPython 3.14, no memory copy is needed, it's just a thin wrapper to
148-
expose Python int internal digits array.
146+
On CPython 3.14, no memory copy is needed, it's just a thin wrapper to
147+
expose Python int internal digits array.
149148
150-
A private field of the :c:struct:`PyLongExport`, if
151-
:c:member:`~PyLongExport.digits` not ``NULL``, stores a strong reference to the
152-
Python :class:`int` object to make sure that that structure remains valid until
153-
:c:func:`PyLong_FreeExport()` is called.
149+
If :c:member:`~PyLongExport.digits` not ``NULL``, a private field of
150+
the :c:struct:`PyLongExport` structure stores a strong reference to
151+
the Python :class:`int` object to make sure that that structure
152+
remains valid until :c:func:`PyLong_FreeExport()` is called.
154153
155154
156155
.. c:function:: void PyLong_FreeExport(PyLongExport *export_long)
@@ -161,7 +160,8 @@ Python :class:`int` object to make sure that that structure remains valid until
161160
Import API
162161
----------
163162
164-
The :c:type:`PyLongWriter` API can be used to import an integer.
163+
The :c:type:`PyLongWriter` API can be used to import an integer:
164+
create a Python :class:`int` object from a digits array.
165165
166166
.. c:struct:: PyLongWriter
167167
@@ -187,8 +187,8 @@ The :c:type:`PyLongWriter` API can be used to import an integer.
187187
in the range [``0``; ``PyLong_BASE - 1``]. Unused digits must be set to
188188
``0``.
189189
190-
On CPython 3.14, the implementation is a thin wrapper to the private
191-
:c:func:`!_PyLong_New()` function.
190+
On CPython 3.14, the implementation is a thin wrapper to the private
191+
:c:func:`!_PyLong_New()` function.
192192
193193
194194
.. c:function:: PyObject* PyLongWriter_Finish(PyLongWriter *writer)
@@ -198,8 +198,8 @@ On CPython 3.14, the implementation is a thin wrapper to the private
198198
On success, return a Python :class:`int` object.
199199
On error, set an exception and return ``NULL``.
200200
201-
:c:func:`PyLongWriter_Finish()` takes care of normalizing the digits and
202-
converts the object to a compact integer if needed.
201+
The function takes care of normalizing the digits and converts the
202+
object to a compact integer if needed.
203203
204204
205205
.. c:function:: void PyLongWriter_Discard(PyLongWriter *writer)
@@ -422,15 +422,22 @@ added.
422422
Discussions
423423
===========
424424
425-
* https://github.com/capi-workgroup/decisions/issues/35
426-
* https://github.com/python/cpython/pull/121339
427-
* https://github.com/python/cpython/issues/102471
425+
* Discourse: `PEP 757 – C API to import-export Python integers
426+
<https://discuss.python.org/t/63895>`_
427+
* `C API Working Group decision issue #35
428+
<https://github.com/capi-workgroup/decisions/issues/35>`_
429+
* `Pull request #121339
430+
<https://github.com/python/cpython/pull/121339>`_
431+
* `Issue #102471
432+
<https://github.com/python/cpython/issues/102471>`_:
433+
The C-API for Python to C integer conversion is, to be frank, a mess.
428434
* `Add public function PyLong_GetDigits()
429435
<https://github.com/capi-workgroup/decisions/issues/31>`_
430436
* `Consider restoring _PyLong_New() function as public
431437
<https://github.com/python/cpython/issues/111415>`_
432-
* `gh-106320: Remove private _PyLong_New() function
433-
<https://github.com/python/cpython/pull/108604>`_
438+
* `Pull request gh-106320
439+
<https://github.com/python/cpython/pull/108604>`_:
440+
Remove private _PyLong_New() function.
434441
435442
436443
Copyright

0 commit comments

Comments
 (0)