bpo-38858: Small integer per interpreter (GH-17315)

Each Python subinterpreter now has its own "small integer
singletons": numbers in [-5; 257] range.

It is no longer possible to change the number of small integers at
build time by overriding NSMALLNEGINTS and NSMALLPOSINTS macros:
macros should now be modified manually in pycore_pystate.h header
file.

For now, continue to share _PyLong_Zero and _PyLong_One singletons
between all subinterpreters.
This commit is contained in:
Victor Stinner 2019-12-17 13:02:18 +01:00 committed by GitHub
parent f501db2b93
commit 630c8df5cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 38 deletions

View file

@ -576,10 +576,11 @@ pycore_init_types(PyThreadState *tstate)
if (_PyStatus_EXCEPTION(status)) {
return status;
}
}
if (!_PyLong_Init()) {
return _PyStatus_ERR("can't init longs");
}
if (!_PyLong_Init(tstate)) {
return _PyStatus_ERR("can't init longs");
}
if (is_main_interp) {
@ -1251,7 +1252,11 @@ finalize_interp_types(PyThreadState *tstate, int is_main_interp)
_PyList_Fini();
_PySet_Fini();
_PyBytes_Fini();
_PyLong_Fini();
}
_PyLong_Fini(tstate);
if (is_main_interp) {
_PyFloat_Fini();
_PyDict_Fini();
_PySlice_Fini();