summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-01-24 05:30:29 (GMT)
committerGitHub <noreply@github.com>2023-01-24 05:30:29 (GMT)
commita259efc63fb784634b66b5f8c8342d60672aaa23 (patch)
treeca32de814a906b7ee42c9698e5e0d336ddaa4d66 /Doc
parent81266281073f498349d6e98563a6519e2b94a1c4 (diff)
downloadcpython-a259efc63fb784634b66b5f8c8342d60672aaa23.zip
cpython-a259efc63fb784634b66b5f8c8342d60672aaa23.tar.gz
cpython-a259efc63fb784634b66b5f8c8342d60672aaa23.tar.bz2
[docs] Mention how to get/set a bigint PyLong via the C API (GH-101270)
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 (cherry picked from commit e244401ce508ad391295beb636e499fcc6797a2a) Co-authored-by: Gregory P. Smith <greg@krypto.org>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/long.rst4
1 files changed, 4 insertions, 0 deletions
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst
index bd3d731..b3e455d 100644
--- a/Doc/c-api/long.rst
+++ b/Doc/c-api/long.rst
@@ -93,6 +93,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
underscores after a base specifier and between digits are ignored. If there
are no digits, :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)