Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit14b4169

Browse files
committed
Convert pocketfft_umath to multi-phase init (PEP 489)
1 parentbbdebae commit14b4169

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

‎numpy/fft/_pocketfft_umath.cpp

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -388,41 +388,44 @@ add_gufuncs(PyObject *dictionary) {
388388
return0;
389389
}
390390

391-
staticstructPyModuleDef moduledef = {
392-
PyModuleDef_HEAD_INIT,
393-
"_multiarray_umath",
394-
NULL,
395-
-1,
396-
NULL,
397-
NULL,
398-
NULL,
399-
NULL,
400-
NULL
401-
};
402-
403-
/* Initialization function for the module*/
404-
PyMODINIT_FUNCPyInit__pocketfft_umath(void)
391+
staticint
392+
_pocketfft_umath_exec(PyObject *m)
405393
{
406-
PyObject *m =PyModule_Create(&moduledef);
407-
if (m ==NULL) {
408-
returnNULL;
409-
}
410-
411394
/* Import the array and ufunc objects*/
412-
import_array();
413-
import_ufunc();
395+
import_array1(-1);
396+
import_umath1(-1);
414397

415398
PyObject *d =PyModule_GetDict(m);
416399
if (add_gufuncs(d) <0) {
417400
Py_DECREF(d);
418401
Py_DECREF(m);
419-
returnNULL;
402+
return-1;
420403
}
421404

422-
#if Py_GIL_DISABLED
423-
// signal this module supports running with the GIL disabled
424-
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
405+
return0;
406+
}
407+
408+
staticstructPyModuleDef_Slot _pocketfft_umath_slots[] = {
409+
{Py_mod_exec, (void*)_pocketfft_umath_exec},
410+
#if PY_VERSION_HEX >= 0x030c00f0// Python 3.12+
411+
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
425412
#endif
413+
#if PY_VERSION_HEX >= 0x030d00f0// Python 3.13+
414+
// signal that this module supports running without an active GIL
415+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
416+
#endif
417+
{0,NULL},
418+
};
419+
420+
staticstructPyModuleDef moduledef = {
421+
PyModuleDef_HEAD_INIT,/* m_base*/
422+
"_pocketfft_umath",/* m_name*/
423+
NULL,/* m_doc*/
424+
0,/* m_size*/
425+
NULL,/* m_methods*/
426+
_pocketfft_umath_slots,/* m_slots*/
427+
};
426428

427-
return m;
429+
PyMODINIT_FUNCPyInit__pocketfft_umath(void) {
430+
returnPyModuleDef_Init(&moduledef);
428431
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp