File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff 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
458460The 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
462468Discussions
You can’t perform that action at this time.
0 commit comments