Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d1fe0cc

Browse filesBrowse files
committed
Mark more modules as not using the GIL
1 parent 77d1652 commit d1fe0cc
Copy full SHA for d1fe0cc

File tree

Expand file treeCollapse file tree

7 files changed

+31
-4
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+31
-4
lines changed

‎Modules/_suggestions.c

Copy file name to clipboardExpand all lines: Modules/_suggestions.c
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,21 @@ static PyMethodDef module_methods[] = {
4949
{NULL, NULL, 0, NULL} // Sentinel
5050
};
5151

52+
static PyModuleDef_Slot module_slots[] = {
53+
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
54+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
55+
{0, NULL},
56+
};
57+
5258
static struct PyModuleDef suggestions_module = {
5359
PyModuleDef_HEAD_INIT,
5460
"_suggestions",
5561
NULL,
56-
-1,
57-
module_methods
62+
0,
63+
module_methods,
64+
module_slots,
5865
};
5966

6067
PyMODINIT_FUNC PyInit__suggestions(void) {
61-
return PyModule_Create(&suggestions_module);
68+
return PyModuleDef_Init(&suggestions_module);
6269
}
63-

‎Modules/_testimportmultiple.c

Copy file name to clipboardExpand all lines: Modules/_testimportmultiple.c
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <Python.h>
1313

1414
static PyModuleDef_Slot shared_slots[] = {
15+
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
1516
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
1617
{0, NULL},
1718
};

‎Modules/_testmultiphase.c

Copy file name to clipboardExpand all lines: Modules/_testmultiphase.c
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,9 @@ PyInit__test_module_state_shared(void)
900900
if (module == NULL) {
901901
return NULL;
902902
}
903+
#ifdef Py_GIL_DISABLED
904+
PyModule_ExperimentalSetGIL(module, Py_MOD_GIL_NOT_USED);
905+
#endif
903906

904907
if (PyModule_AddObjectRef(module, "Error", PyExc_Exception) < 0) {
905908
Py_DECREF(module);
@@ -932,6 +935,7 @@ PyInit__testmultiphase_multiple_multiple_interpreters_slots(void)
932935
static PyModuleDef_Slot non_isolated_slots[] = {
933936
{Py_mod_exec, execfunc},
934937
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
938+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
935939
{0, NULL},
936940
};
937941

@@ -952,6 +956,7 @@ static PyModuleDef_Slot shared_gil_only_slots[] = {
952956
We put it here explicitly to draw attention to the contrast
953957
with Py_MOD_PER_INTERPRETER_GIL_SUPPORTED. */
954958
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED},
959+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
955960
{0, NULL},
956961
};
957962

‎Modules/_testsinglephase.c

Copy file name to clipboardExpand all lines: Modules/_testsinglephase.c
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ PyInit__testsinglephase_with_reinit(void)
399399
if (module == NULL) {
400400
return NULL;
401401
}
402+
#ifdef Py_GIL_DISABLED
403+
PyModule_ExperimentalSetGIL(module, Py_MOD_GIL_NOT_USED);
404+
#endif
402405

403406
assert(get_module_state(module) == NULL);
404407

@@ -461,6 +464,9 @@ PyInit__testsinglephase_with_state(void)
461464
if (module == NULL) {
462465
return NULL;
463466
}
467+
#ifdef Py_GIL_DISABLED
468+
PyModule_ExperimentalSetGIL(module, Py_MOD_GIL_NOT_USED);
469+
#endif
464470

465471
module_state *state = get_module_state(module);
466472
assert(state != NULL);

‎Modules/_tracemalloc.c

Copy file name to clipboardExpand all lines: Modules/_tracemalloc.c
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ PyInit__tracemalloc(void)
219219
m = PyModule_Create(&module_def);
220220
if (m == NULL)
221221
return NULL;
222+
#ifdef Py_GIL_DISABLED
223+
PyModule_ExperimentalSetGIL(m, Py_MOD_GIL_NOT_USED);
224+
#endif
222225

223226
if (_PyTraceMalloc_Init() < 0) {
224227
Py_DECREF(m);

‎Python/bltinmodule.c

Copy file name to clipboardExpand all lines: Python/bltinmodule.c
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,6 +3124,9 @@ _PyBuiltin_Init(PyInterpreterState *interp)
31243124
mod = _PyModule_CreateInitialized(&builtinsmodule, PYTHON_API_VERSION);
31253125
if (mod == NULL)
31263126
return NULL;
3127+
#ifdef Py_GIL_DISABLED
3128+
PyModule_ExperimentalSetGIL(mod, Py_MOD_GIL_NOT_USED);
3129+
#endif
31273130
dict = PyModule_GetDict(mod);
31283131

31293132
#ifdef Py_TRACE_REFS

‎Python/sysmodule.c

Copy file name to clipboardExpand all lines: Python/sysmodule.c
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3740,6 +3740,9 @@ _PySys_Create(PyThreadState *tstate, PyObject **sysmod_p)
37403740
if (sysmod == NULL) {
37413741
return _PyStatus_ERR("failed to create a module object");
37423742
}
3743+
#ifdef Py_GIL_DISABLED
3744+
PyModule_ExperimentalSetGIL(sysmod, Py_MOD_GIL_NOT_USED);
3745+
#endif
37433746

37443747
PyObject *sysdict = PyModule_GetDict(sysmod);
37453748
if (sysdict == NULL) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.