diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2021-12-14 01:04:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-14 01:04:05 (GMT) |
commit | 121f1f893a39d0b58d3d2b5597505c154ecaac2a (patch) | |
tree | 2efda2489f892c98015cf80763369ea4f3505666 /Objects | |
parent | cb589d1b6bad4b75852c2e2a471a3800d5efdca7 (diff) | |
download | cpython-121f1f893a39d0b58d3d2b5597505c154ecaac2a.zip cpython-121f1f893a39d0b58d3d2b5597505c154ecaac2a.tar.gz cpython-121f1f893a39d0b58d3d2b5597505c154ecaac2a.tar.bz2 |
bpo-45953: Statically initialize the small ints. (gh-30092)
The array of small PyLong objects has been statically declared. Here I also statically initialize them. Consequently they are no longer initialized dynamically during runtime init.
I've also moved them under a new sub-struct in _PyRuntimeState, in preparation for static allocation and initialization of other global objects.
https://bugs.python.org/issue45953
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/longobject.c | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index f6d5e76..77434e6 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5832,29 +5832,6 @@ PyLong_GetInfo(void) /* runtime lifecycle */ -void -_PyLong_InitGlobalObjects(PyInterpreterState *interp) -{ - if (!_Py_IsMainInterpreter(interp)) { - return; - } - - PyLongObject *small_ints = _PyLong_SMALL_INTS; - if (small_ints[0].ob_base.ob_base.ob_refcnt != 0) { - // Py_Initialize() must be running a second time. - return; - } - - for (Py_ssize_t i=0; i < _PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS; i++) { - sdigit ival = (sdigit)i - _PY_NSMALLNEGINTS; - int size = (ival < 0) ? -1 : ((ival == 0) ? 0 : 1); - small_ints[i].ob_base.ob_base.ob_refcnt = 1; - small_ints[i].ob_base.ob_base.ob_type = &PyLong_Type; - small_ints[i].ob_base.ob_size = size; - small_ints[i].ob_digit[0] = (digit)abs(ival); - } -} - PyStatus _PyLong_InitTypes(PyInterpreterState *interp) { @@ -5875,9 +5852,3 @@ _PyLong_InitTypes(PyInterpreterState *interp) return _PyStatus_OK(); } - -void -_PyLong_Fini(PyInterpreterState *interp) -{ - (void)interp; -} |