@@ -75,7 +75,7 @@ Data needed by `GMP <https://gmplib.org/>`_-like import-export functions.
75
75
- ``1 `` for most significant digit first
76
76
- ``-1 `` for least significant digit first
77
77
78
- .. c :member :: int8_t endian
78
+ .. c :member :: int8_t endianness
79
79
80
80
Digit endianness:
81
81
@@ -89,11 +89,10 @@ Data needed by `GMP <https://gmplib.org/>`_-like import-export functions.
89
89
90
90
See the :c:struct:`PyLongLayout` structure.
91
91
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.
97
96
98
97
99
98
Export API
@@ -141,16 +140,16 @@ Export API
141
140
This function always succeeds if *obj * is a Python :class: `int ` object or a
142
141
subclass.
143
142
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
145
144
called when the export is no longer needed.
146
145
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.
149
148
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.
154
153
155
154
156
155
.. 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
161
160
Import API
162
161
----------
163
162
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.
165
165
166
166
.. c :struct :: PyLongWriter
167
167
@@ -187,8 +187,8 @@ The :c:type:`PyLongWriter` API can be used to import an integer.
187
187
in the range [``0 ``; ``PyLong_BASE - 1 ``]. Unused digits must be set to
188
188
``0 ``.
189
189
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.
192
192
193
193
194
194
.. c :function :: PyObject* PyLongWriter_Finish (PyLongWriter *writer)
@@ -198,8 +198,8 @@ On CPython 3.14, the implementation is a thin wrapper to the private
198
198
On success, return a Python :class: `int ` object.
199
199
On error, set an exception and return ``NULL ``.
200
200
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.
203
203
204
204
205
205
.. c :function :: void PyLongWriter_Discard (PyLongWriter *writer)
@@ -422,15 +422,22 @@ added.
422
422
Discussions
423
423
===========
424
424
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.
428
434
* `Add public function PyLong_GetDigits()
429
435
<https://github.com/capi-workgroup/decisions/issues/31> `_
430
436
* `Consider restoring _PyLong_New() function as public
431
437
<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.
434
441
435
442
436
443
Copyright
0 commit comments