]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[docs] Mention how to get/set a bigint PyLong via the C API (#101270)
authorGregory P. Smith <greg@krypto.org>
Tue, 24 Jan 2023 05:20:53 +0000 (21:20 -0800)
committerGitHub <noreply@github.com>
Tue, 24 Jan 2023 05:20:53 +0000 (21:20 -0800)
We don't need direct C APIs to get at a bigint representation of PyLong but we
do want the few people who need to understand how.

Additional Author:  CAM-Gerlach

Doc/c-api/long.rst

index 4f6f865db8be13cb77c9d12addcb460cad3d2bcd..41b5632d23003f0207232edb41482e3f4ecfd559 100644 (file)
@@ -94,6 +94,10 @@ distinguished from a number.  Use :c:func:`PyErr_Occurred` to disambiguate.
    ignored.  If there are no digits or *str* is not NULL-terminated following the
    digits and trailing whitespace, :exc:`ValueError` will be raised.
 
+   .. seealso:: Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes`
+      to convert a :c:type:`PyLongObject` to/from an array of bytes in base
+      ``256``. You can call those from C using :c:func:`PyObject_CallMethod`.
+
 
 .. c:function:: PyObject* PyLong_FromUnicodeObject(PyObject *u, int base)