Skip to content

Commit 9512ad7

Browse files
authored
[3.9] bpo-40514: Remove --with-experimental-isolated-subinterpreters in 3.9 (GH-20228)
Remove --with-experimental-isolated-subinterpreters configure option in Python 3.9: the experiment continues in the master branch, but it's no longer needed in 3.9.
1 parent b008445 commit 9512ad7

21 files changed

+7
-236
lines changed

Include/internal/pycore_ceval.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ extern PyObject *_PyEval_EvalCode(
5050
PyObject *kwdefs, PyObject *closure,
5151
PyObject *name, PyObject *qualname);
5252

53-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
54-
extern int _PyEval_ThreadsInitialized(PyInterpreterState *interp);
55-
#else
5653
extern int _PyEval_ThreadsInitialized(struct pyruntimestate *runtime);
57-
#endif
5854
extern PyStatus _PyEval_InitGIL(PyThreadState *tstate);
5955
extern void _PyEval_FiniGIL(PyThreadState *tstate);
6056

Include/internal/pycore_interp.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ struct _ceval_state {
4646
/* Request for dropping the GIL */
4747
_Py_atomic_int gil_drop_request;
4848
struct _pending_calls pending;
49-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
50-
struct _gil_runtime_state gil;
51-
#endif
5249
};
5350

5451
/* fs_codec.encoding is initialized to NULL.

Include/internal/pycore_pystate.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,10 @@ _Py_ThreadCanHandlePendingCalls(void)
4949
/* Variable and macro for in-line access to current thread
5050
and interpreter state */
5151

52-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
53-
PyAPI_FUNC(PyThreadState*) _PyThreadState_GetTSS(void);
54-
#endif
55-
5652
static inline PyThreadState*
5753
_PyRuntimeState_GetThreadState(_PyRuntimeState *runtime)
5854
{
59-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
60-
return _PyThreadState_GetTSS();
61-
#else
6255
return (PyThreadState*)_Py_atomic_load_relaxed(&runtime->gilstate.tstate_current);
63-
#endif
6456
}
6557

6658
/* Get the current Python thread state.
@@ -75,11 +67,7 @@ _PyRuntimeState_GetThreadState(_PyRuntimeState *runtime)
7567
static inline PyThreadState*
7668
_PyThreadState_GET(void)
7769
{
78-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
79-
return _PyThreadState_GetTSS();
80-
#else
8170
return _PyRuntimeState_GetThreadState(&_PyRuntime);
82-
#endif
8371
}
8472

8573
/* Redefine PyThreadState_GET() as an alias to _PyThreadState_GET() */

Include/internal/pycore_runtime.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ struct _ceval_runtime_state {
1919
the main thread of the main interpreter can handle signals: see
2020
_Py_ThreadCanHandleSignals(). */
2121
_Py_atomic_int signals_pending;
22-
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
2322
struct _gil_runtime_state gil;
24-
#endif
2523
};
2624

2725
/* GIL state */
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove ``--with-experimental-isolated-subinterpreters`` configure option in
2+
Python 3.9: the experiment continues in the master branch, but it's no
3+
longer needed in 3.9.

Modules/_xxsubinterpretersmodule.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,20 +1939,6 @@ _run_script_in_interpreter(PyInterpreterState *interp, const char *codestr,
19391939
return -1;
19401940
}
19411941

1942-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
1943-
// Switch to interpreter.
1944-
PyThreadState *new_tstate = PyInterpreterState_ThreadHead(interp);
1945-
PyThreadState *save1 = PyEval_SaveThread();
1946-
1947-
(void)PyThreadState_Swap(new_tstate);
1948-
1949-
// Run the script.
1950-
_sharedexception *exc = NULL;
1951-
int result = _run_script(interp, codestr, shared, &exc);
1952-
1953-
// Switch back.
1954-
PyEval_RestoreThread(save1);
1955-
#else
19561942
// Switch to interpreter.
19571943
PyThreadState *save_tstate = NULL;
19581944
if (interp != PyInterpreterState_Get()) {
@@ -1970,7 +1956,6 @@ _run_script_in_interpreter(PyInterpreterState *interp, const char *codestr,
19701956
if (save_tstate != NULL) {
19711957
PyThreadState_Swap(save_tstate);
19721958
}
1973-
#endif
19741959

19751960
// Propagate any exception out to the caller.
19761961
if (exc != NULL) {

Modules/gcmodule.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,14 +1181,6 @@ collect(PyThreadState *tstate, int generation,
11811181
_PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
11821182
GCState *gcstate = &tstate->interp->gc;
11831183

1184-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
1185-
if (tstate->interp->config._isolated_interpreter) {
1186-
// bpo-40533: The garbage collector must not be run on parallel on
1187-
// Python objects shared by multiple interpreters.
1188-
return 0;
1189-
}
1190-
#endif
1191-
11921184
if (gcstate->debug & DEBUG_STATS) {
11931185
PySys_WriteStderr("gc: collecting generation %d...\n", generation);
11941186
show_stats_each_generations(gcstate);

Objects/dictobject.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,6 @@ static uint64_t pydict_global_version = 0;
251251
#define PyDict_MAXFREELIST 80
252252
#endif
253253

254-
/* bpo-40521: dict free lists are shared by all interpreters. */
255-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
256-
# undef PyDict_MAXFREELIST
257-
# define PyDict_MAXFREELIST 0
258-
#endif
259-
260254
#if PyDict_MAXFREELIST > 0
261255
static PyDictObject *free_list[PyDict_MAXFREELIST];
262256
static int numfree = 0;

Objects/frameobject.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -559,12 +559,6 @@ static PyGetSetDef frame_getsetlist[] = {
559559
/* max value for numfree */
560560
#define PyFrame_MAXFREELIST 200
561561

562-
/* bpo-40521: frame free lists are shared by all interpreters. */
563-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
564-
# undef PyFrame_MAXFREELIST
565-
# define PyFrame_MAXFREELIST 0
566-
#endif
567-
568562
#if PyFrame_MAXFREELIST > 0
569563
static PyFrameObject *free_list = NULL;
570564
static int numfree = 0; /* number of frames currently in free_list */

Objects/listobject.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,6 @@ list_preallocate_exact(PyListObject *self, Py_ssize_t size)
101101
# define PyList_MAXFREELIST 80
102102
#endif
103103

104-
/* bpo-40521: list free lists are shared by all interpreters. */
105-
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
106-
# undef PyList_MAXFREELIST
107-
# define PyList_MAXFREELIST 0
108-
#endif
109-
110104
static PyListObject *free_list[PyList_MAXFREELIST];
111105
static int numfree = 0;
112106

0 commit comments

Comments
 (0)