Skip to content

Commit 03bbdce

Browse files
committed
PEP 757: edit rejected ideas (mpz_import/export-like API)
1 parent a159185 commit 03bbdce

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

peps/pep-0757.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,17 @@ API example::
452452
int PyLong_Export(PyLongObject *obj, PyLongLayout layout, void *buffer);
453453
PyLongObject *PyLong_Import(PyLongLayout layout, void *buffer);
454454
455-
This might work for the GMP, as this it has :c:func:`!mpz_limbs_read()` and
456-
:c:func:`!mpz_limbs_write()` functions, that can provide required "buffers".
455+
This might work for the GMP, as it has :c:func:`!mpz_limbs_read()` and
456+
:c:func:`!mpz_limbs_write()` functions, that can provide required access to
457+
internals of :c:struct:`!mpz_t`. Other libraries may require using temporary
458+
bufferes and then mpz_import/export-like functions on their side.
457459
458460
The major drawback of this approach is that it's much more complex on the
459-
CPython side (i.e. actual conversion between different layouts).
461+
CPython side (i.e. actual conversion between different layouts). For example,
462+
implementation of the :c:func:`PyLong_FromNativeBytes()` and the
463+
:c:func:`PyLong_AsNativeBytes()` (together provided restricted version of the
464+
required API) in the CPython took ~500 LOC (c.f. ~100 LOC in the current
465+
implementation).
460466
461467
462468
Discussions

0 commit comments

Comments
 (0)