From 4cded543ed920ba636debc7af024601e20f48e36 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 17 Sep 2024 10:02:06 +0300 Subject: [PATCH] XXX _reserved --- peps/pep-0757.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/peps/pep-0757.rst b/peps/pep-0757.rst index f19c91b4005..95f9ad205b0 100644 --- a/peps/pep-0757.rst +++ b/peps/pep-0757.rst @@ -100,6 +100,9 @@ Export a Python integer as a digits array:: // Read-only array of unsigned digits. const void *digits; + + // Member used internally, must not be used for other purpose. + Py_uintptr_t _reserved; } PyLong_DigitArray; PyAPI_FUNC(int) PyLong_Export(PyObject *obj, PyLong_DigitArray *array); @@ -107,6 +110,10 @@ Export a Python integer as a digits array:: On CPython 3.14, no memory copy is needed, it's just a thin wrapper to expose Python int internal digits array. +``PyLong_DigitArray._reserved`` stores a strong reference to the Python +:class:`int` object to make sure that that structure remains valid until +``PyLong_FreeExport()`` is called. + PyLong_Export() ^^^^^^^^^^^^^^^