summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-01-30 10:03:04 (GMT)
committerGitHub <noreply@github.com>2023-01-30 10:03:04 (GMT)
commitc1b1f51cd1632f0b77dacd43092fb44ed5e053a9 (patch)
treeda815b0f6e2daddbb013ce2383837c61b3675201 /Include
parentf5a3d91b6c56ddff4644b5a5ac34d8c6d23d7c79 (diff)
downloadcpython-c1b1f51cd1632f0b77dacd43092fb44ed5e053a9.zip
cpython-c1b1f51cd1632f0b77dacd43092fb44ed5e053a9.tar.gz
cpython-c1b1f51cd1632f0b77dacd43092fb44ed5e053a9.tar.bz2
GH-101291: Refactor the `PyLongObject` struct into object header and PyLongValue struct. (GH-101292)
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/longintrepr.h9
-rw-r--r--Include/internal/pycore_runtime_init.h8
2 files changed, 12 insertions, 5 deletions
diff --git a/Include/cpython/longintrepr.h b/Include/cpython/longintrepr.h
index 6d52427..810daa8 100644
--- a/Include/cpython/longintrepr.h
+++ b/Include/cpython/longintrepr.h
@@ -79,9 +79,14 @@ typedef long stwodigits; /* signed variant of twodigits */
aware that ints abuse ob_size's sign bit.
*/
-struct _longobject {
- PyObject_VAR_HEAD
+typedef struct _PyLongValue {
+ Py_ssize_t ob_size; /* Number of items in variable part */
digit ob_digit[1];
+} _PyLongValue;
+
+struct _longobject {
+ PyObject_HEAD
+ _PyLongValue long_value;
};
PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t);
diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h
index f10dccc..c6a27d0 100644
--- a/Include/internal/pycore_runtime_init.h
+++ b/Include/internal/pycore_runtime_init.h
@@ -149,9 +149,11 @@ extern "C" {
#define _PyLong_DIGIT_INIT(val) \
{ \
- _PyVarObject_IMMORTAL_INIT(&PyLong_Type, \
- ((val) == 0 ? 0 : ((val) > 0 ? 1 : -1))), \
- .ob_digit = { ((val) >= 0 ? (val) : -(val)) }, \
+ .ob_base = _PyObject_IMMORTAL_INIT(&PyLong_Type), \
+ .long_value = { \
+ ((val) == 0 ? 0 : ((val) > 0 ? 1 : -1)), \
+ { ((val) >= 0 ? (val) : -(val)) }, \
+ } \
}
#define _PyBytes_SIMPLE_INIT(CH, LEN) \