Skip to content

Commit f6465bd

Browse files
committed
Shrink slots
1 parent d68e3e3 commit f6465bd

8 files changed

Lines changed: 9 additions & 79 deletions

File tree

Doc/c-api/intro.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ complete listing.
130130
.m_base = PyModuleDef_HEAD_INIT,
131131
.m_name = "spam",
132132
.m_size = 0,
133-
.m_slots = spam_module_slots,
134133
...
135134
};
136135

Doc/extending/embedding.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -251,24 +251,11 @@ Python extension. For example::
251251
{NULL, NULL, 0, NULL}
252252
};
253253

254-
static PyModuleDef_Slot emb_module_slots[] = {
255-
#ifdef Py_mod_multiple_interpreters
256-
// signal that this module can be imported in isolated subinterpreters
257-
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
258-
#endif
259-
#ifdef Py_mod_gil
260-
// signal that this module supports running without an active GIL
261-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
262-
#endif
263-
{0, NULL}
264-
};
265-
266254
struct PyModuleDef emb_module = {
267255
.m_base = PyModuleDef_HEAD_INIT,
268256
.m_name = "emb",
269257
.m_size = 0,
270258
.m_methods = emb_module_methods,
271-
.m_slots = emb_module_slots,
272259
};
273260

274261
static PyObject*

Doc/extending/extending.rst

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,6 @@ with an exception object::
259259

260260
static PyModuleDef_Slot spam_module_slots[] = {
261261
{Py_mod_exec, spam_module_exec},
262-
#ifdef Py_mod_multiple_interpreters
263-
// signal that this module can be imported in isolated subinterpreters
264-
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
265-
#endif
266-
#ifdef Py_mod_gil
267-
// signal that this module supports running without an active GIL
268-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
269-
#endif
270262
{0, NULL}
271263
};
272264

@@ -484,15 +476,15 @@ optionally followed by an import of the module::
484476
.. note::
485477

486478
If you define *static* extension types rather than heap-allocated types,
487-
the module can create the same problems as the legacy single-phase
479+
the module can cause the same problems as the legacy single-phase
488480
initialization when removing entries from ``sys.modules`` or importing
489481
compiled modules into multiple interpreters within a process
490482
(or following a :c:func:`fork` without an intervening :c:func:`exec`).
491-
In this case, at least the :c:data:`Py_mod_multiple_interpreters` slot
492-
in the examples should be ``Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED``.
483+
In this case, at least the module should reject subinterpreters by using
484+
a :c:type:`PyModuleDef_Slot` (``Py_mod_multiple_interpreters``).
493485

494486
A more substantial example module is included in the Python source distribution
495-
as :file:`Modules/xxlimited.c`. This file may be used as a template or simply
487+
as :file:`Modules/xxlimited.c`. This file may be used as a template or simply
496488
read as an example.
497489

498490
.. _compilation:
@@ -834,22 +826,11 @@ Philbrick (philbrick@hks.com)::
834826
{NULL, NULL, 0, NULL} /* sentinel */
835827
};
836828

837-
static PyModuleDef_Slot keywdarg_slots[] = {
838-
#ifdef Py_mod_multiple_interpreters
839-
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
840-
#endif
841-
#ifdef Py_mod_gil
842-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
843-
#endif
844-
{0, NULL}
845-
};
846-
847829
static struct PyModuleDef keywdarg_module = {
848830
.m_base = PyModuleDef_HEAD_INIT,
849831
.m_name = "keywdarg",
850832
.m_size = 0,
851833
.m_methods = keywdarg_methods,
852-
.m_slots = keywdarg_slots,
853834
};
854835

855836
PyMODINIT_FUNC
@@ -1343,12 +1324,6 @@ function must take care of initializing the C API pointer array::
13431324

13441325
static PyModuleDef_Slot spam_module_slots[] = {
13451326
{Py_mod_exec, spam_module_exec},
1346-
#ifdef Py_mod_multiple_interpreters
1347-
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
1348-
#endif
1349-
#ifdef Py_mod_gil
1350-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
1351-
#endif
13521327
{0, NULL}
13531328
};
13541329

@@ -1426,12 +1401,6 @@ like this::
14261401

14271402
static PyModuleDef_Slot client_module_slots[] = {
14281403
{Py_mod_exec, client_module_exec},
1429-
#ifdef Py_mod_multiple_interpreters
1430-
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
1431-
#endif
1432-
#ifdef Py_mod_gil
1433-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
1434-
#endif
14351404
{0, NULL}
14361405
};
14371406

Doc/includes/newtypes/custom.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@ custom_module_exec(PyObject *mod)
3131

3232
static PyModuleDef_Slot custom_module_slots[] = {
3333
{Py_mod_exec, custom_module_exec},
34-
#ifdef Py_mod_multiple_interpreters
35-
// Py_MOD_PER_INTERPRETER_GIL_SUPPORTED requires heaptypes
34+
// Just use this while using static types
3635
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
37-
#endif
38-
#ifdef Py_mod_gil
39-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
40-
#endif
4136
{0, NULL}
4237
};
4338

Doc/includes/newtypes/custom2.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,8 @@ custom_module_exec(PyObject *mod)
121121

122122
static PyModuleDef_Slot custom_module_slots[] = {
123123
{Py_mod_exec, custom_module_exec},
124-
#ifdef Py_mod_multiple_interpreters
125-
// Py_MOD_PER_INTERPRETER_GIL_SUPPORTED requires heaptypes
124+
// Just use this while using static types
126125
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
127-
#endif
128-
#ifdef Py_mod_gil
129-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
130-
#endif
131126
{0, NULL}
132127
};
133128

Doc/includes/newtypes/custom3.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,8 @@ custom_module_exec(PyObject *mod)
166166

167167
static PyModuleDef_Slot custom_module_slots[] = {
168168
{Py_mod_exec, custom_module_exec},
169-
#ifdef Py_mod_multiple_interpreters
170-
// Py_MOD_PER_INTERPRETER_GIL_SUPPORTED requires heaptypes
169+
// Just use this while using static types
171170
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
172-
#endif
173-
#ifdef Py_mod_gil
174-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
175-
#endif
176171
{0, NULL}
177172
};
178173

Doc/includes/newtypes/custom4.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,8 @@ custom_module_exec(PyObject *mod)
185185

186186
static PyModuleDef_Slot custom_module_slots[] = {
187187
{Py_mod_exec, custom_module_exec},
188-
#ifdef Py_mod_multiple_interpreters
189-
// Py_MOD_PER_INTERPRETER_GIL_SUPPORTED requires heaptypes
188+
// Just use this while using static types
190189
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
191-
#endif
192-
#ifdef Py_mod_gil
193-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
194-
#endif
195190
{0, NULL}
196191
};
197192

Doc/includes/newtypes/sublist.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,8 @@ sublist_module_exec(PyObject *mod)
5757

5858
static PyModuleDef_Slot sublist_module_slots[] = {
5959
{Py_mod_exec, sublist_module_exec},
60-
#ifdef Py_mod_multiple_interpreters
61-
// Py_MOD_PER_INTERPRETER_GIL_SUPPORTED requires heaptypes
60+
// Just use this while using static types
6261
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
63-
#endif
64-
#ifdef Py_mod_gil
65-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
66-
#endif
6762
{0, NULL}
6863
};
6964

0 commit comments

Comments
 (0)