[Python-checkins] [docs] Mention how to get/set a bigint PyLong via the C API (GH-101270)

miss-islington webhook-mailer at python.org
Tue Jan 24 00:30:35 EST 2023


https://github.com/python/cpython/commit/a259efc63fb784634b66b5f8c8342d60672aaa23
commit: a259efc63fb784634b66b5f8c8342d60672aaa23
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2023-01-23T21:30:29-08:00
summary:

[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 at krypto.org>

files:
M Doc/c-api/long.rst

diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst
index bd3d731d8464..b3e455d0a89c 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)
 



More information about the Python-checkins mailing list