mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
GH-101291: Rearrange the size bits in PyLongObject (GH-102464)
* Eliminate all remaining uses of Py_SIZE and Py_SET_SIZE on PyLongObject, adding asserts. * Change layout of size/sign bits in longobject to support future addition of immortal ints and tagged medium ints. * Add functions to hide some internals of long object, and for setting sign and digit count. * Replace uses of IS_MEDIUM_VALUE macro with _PyLong_IsCompact().
This commit is contained in:
parent
713df2c534
commit
7559f5fda9
25 changed files with 982 additions and 898 deletions
|
@ -32,6 +32,8 @@ Copyright (C) 1994 Steen Lumholt.
|
|||
# include "pycore_fileutils.h" // _Py_stat()
|
||||
#endif
|
||||
|
||||
#include "pycore_long.h"
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
@ -886,7 +888,8 @@ asBignumObj(PyObject *value)
|
|||
const char *hexchars;
|
||||
mp_int bigValue;
|
||||
|
||||
neg = Py_SIZE(value) < 0;
|
||||
assert(PyLong_Check(value));
|
||||
neg = _PyLong_IsNegative((PyLongObject *)value);
|
||||
hexstr = _PyLong_Format(value, 16);
|
||||
if (hexstr == NULL)
|
||||
return NULL;
|
||||
|
@ -1950,7 +1953,7 @@ _tkinter_tkapp_getboolean(TkappObject *self, PyObject *arg)
|
|||
int v;
|
||||
|
||||
if (PyLong_Check(arg)) { /* int or bool */
|
||||
return PyBool_FromLong(Py_SIZE(arg) != 0);
|
||||
return PyBool_FromLong(!_PyLong_IsZero((PyLongObject *)arg));
|
||||
}
|
||||
|
||||
if (PyTclObject_Check(arg)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue