mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Store actual ints, not pointers to them in the interpreter state. (GH-29274)
This commit is contained in:
parent
13d9205f40
commit
4fc68560ea
5 changed files with 10 additions and 21 deletions
|
@ -335,7 +335,7 @@ struct _is {
|
|||
The integers that are preallocated are those in the range
|
||||
-_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (not inclusive).
|
||||
*/
|
||||
PyLongObject* small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS];
|
||||
PyLongObject small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS];
|
||||
struct _Py_bytes_state bytes;
|
||||
struct _Py_unicode_state unicode;
|
||||
struct _Py_float_state float_state;
|
||||
|
|
|
@ -17,7 +17,7 @@ static inline PyObject* __PyLong_GetSmallInt_internal(int value)
|
|||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
assert(-_PY_NSMALLNEGINTS <= value && value < _PY_NSMALLPOSINTS);
|
||||
size_t index = _PY_NSMALLNEGINTS + value;
|
||||
PyObject *obj = (PyObject*)interp->small_ints[index];
|
||||
PyObject *obj = (PyObject*)&interp->small_ints[index];
|
||||
// _PyLong_GetZero(), _PyLong_GetOne() and get_small_int() must not be
|
||||
// called before _PyLong_Init() nor after _PyLong_Fini().
|
||||
assert(obj != NULL);
|
||||
|
|
|
@ -53,7 +53,7 @@ extern PyStatus _PyUnicode_Init(PyInterpreterState *interp);
|
|||
extern PyStatus _PyUnicode_InitTypes(void);
|
||||
extern PyStatus _PyBytes_Init(PyInterpreterState *interp);
|
||||
extern int _PyStructSequence_Init(void);
|
||||
extern int _PyLong_Init(PyInterpreterState *interp);
|
||||
extern void _PyLong_Init(PyInterpreterState *interp);
|
||||
extern int _PyLong_InitTypes(void);
|
||||
extern PyStatus _PyTuple_Init(PyInterpreterState *interp);
|
||||
extern PyStatus _PyFaulthandler_Init(int enable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue