summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-12-17 12:02:18 (GMT)
committerGitHub <noreply@github.com>2019-12-17 12:02:18 (GMT)
commit630c8df5cf126594f8c1c4579c1888ca80a29d59 (patch)
tree7114d3190806b8b23b23211c0fdc8e0c507ff0c1 /Python/pylifecycle.c
parentf501db2b93a9d3d840b6fb38d6bdda8bcc400d4a (diff)
downloadcpython-630c8df5cf126594f8c1c4579c1888ca80a29d59.zip
cpython-630c8df5cf126594f8c1c4579c1888ca80a29d59.tar.gz
cpython-630c8df5cf126594f8c1c4579c1888ca80a29d59.tar.bz2
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.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 823d96e..4f05dfc 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -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();