File tree 2 files changed +50
-10
lines changed
numpy/_core/tests/examples/limited_api
2 files changed +50
-10
lines changed Original file line number Diff line number Diff line change 4
4
#include <numpy/arrayobject.h>
5
5
#include <numpy/ufuncobject.h>
6
6
7
- static PyModuleDef moduledef = {
7
+ static int
8
+ _limited_api1_exec (void )
9
+ {
10
+ import_array1 (-1 );
11
+ import_umath1 (-1 );
12
+ return 0 ;
13
+ }
14
+
15
+ static struct PyModuleDef_Slot limited_api1_slots [] = {
16
+ {Py_mod_exec , _limited_api1_exec },
17
+ #if PY_VERSION_HEX >= 0x030c00f0 // Python 3.12+
18
+ {Py_mod_multiple_interpreters , Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED },
19
+ #endif
20
+ #if PY_VERSION_HEX >= 0x030d00f0 // Python 3.13+
21
+ // signal that this module supports running without an active GIL
22
+ {Py_mod_gil , Py_MOD_GIL_NOT_USED },
23
+ #endif
24
+ {0 , NULL },
25
+ };
26
+
27
+ static struct PyModuleDef moduledef = {
8
28
.m_base = PyModuleDef_HEAD_INIT ,
9
- .m_name = "limited_api1"
29
+ .m_name = "limited_api1" ,
30
+ .m_size = 0 ,
31
+ .m_slots = limited_api1_slots ,
10
32
};
11
33
12
34
PyMODINIT_FUNC PyInit_limited_api1 (void )
13
35
{
14
- import_array ();
15
- import_umath ();
16
- return PyModule_Create (& moduledef );
36
+ return PyModuleDef_Init (& moduledef );
17
37
}
Original file line number Diff line number Diff line change 6
6
#include <numpy/arrayobject.h>
7
7
#include <numpy/ufuncobject.h>
8
8
9
- static PyModuleDef moduledef = {
9
+ static int
10
+ _limited_api_latest_exec (void )
11
+ {
12
+ import_array1 (-1 );
13
+ import_umath1 (-1 );
14
+ return 0 ;
15
+ }
16
+
17
+ static struct PyModuleDef_Slot limited_api_latest_slots [] = {
18
+ {Py_mod_exec , _limited_api_latest_exec },
19
+ #if PY_VERSION_HEX >= 0x030c00f0 // Python 3.12+
20
+ {Py_mod_multiple_interpreters , Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED },
21
+ #endif
22
+ #if PY_VERSION_HEX >= 0x030d00f0 // Python 3.13+
23
+ // signal that this module supports running without an active GIL
24
+ {Py_mod_gil , Py_MOD_GIL_NOT_USED },
25
+ #endif
26
+ {0 , NULL },
27
+ };
28
+
29
+ static struct PyModuleDef moduledef = {
10
30
.m_base = PyModuleDef_HEAD_INIT ,
11
- .m_name = "limited_api_latest"
31
+ .m_name = "limited_api_latest" ,
32
+ .m_size = 0 ,
33
+ .m_slots = limited_api_latest_slots ,
12
34
};
13
35
14
36
PyMODINIT_FUNC PyInit_limited_api_latest (void )
15
37
{
16
- import_array ();
17
- import_umath ();
18
- return PyModule_Create (& moduledef );
38
+ return PyModuleDef_Init (& moduledef );
19
39
}
You can’t perform that action at this time.
0 commit comments