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

MAINT: declare that NumPy's C extensions support running without the GIL #26913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions 6 numpy/_core/src/_simd/_simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ PyMODINIT_FUNC PyInit__simd(void)
NPY__CPU_DISPATCH_CALL(NPY_CPU_HAVE, ATTACH_MODULE, MAKE_MSVC_HAPPY)
NPY__CPU_DISPATCH_BASELINE_CALL(ATTACH_BASELINE_MODULE, MAKE_MSVC_HAPPY)
#endif

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;
err:
Py_DECREF(m);
Expand Down
6 changes: 6 additions & 0 deletions 6 numpy/_core/src/multiarray/_multiarray_tests.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,12 @@ PyMODINIT_FUNC PyInit__multiarray_tests(void)
PyErr_SetString(PyExc_RuntimeError,
"cannot load _multiarray_tests module.");
}

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;
}

Expand Down
5 changes: 5 additions & 0 deletions 5 numpy/_core/src/multiarray/multiarraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5132,6 +5132,11 @@ PyMODINIT_FUNC PyInit__multiarray_umath(void) {
goto err;
}

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;

err:
Expand Down
5 changes: 5 additions & 0 deletions 5 numpy/_core/src/umath/_operand_flag_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ PyMODINIT_FUNC PyInit__operand_flag_tests(void)
((PyUFuncObject*)ufunc)->iter_flags = NPY_ITER_REDUCE_OK;
PyModule_AddObject(m, "inplace_add", (PyObject*)ufunc);

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;

fail:
Expand Down
5 changes: 5 additions & 0 deletions 5 numpy/_core/src/umath/_rational_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,11 @@ PyMODINIT_FUNC PyInit__rational_tests(void) {
GCD_LCM_UFUNC(gcd,NPY_INT64,"greatest common denominator of two integers");
GCD_LCM_UFUNC(lcm,NPY_INT64,"least common multiple of two integers");

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;

fail:
Expand Down
6 changes: 6 additions & 0 deletions 6 numpy/_core/src/umath/_struct_ufunc_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,11 @@ PyMODINIT_FUNC PyInit__struct_ufunc_tests(void)

PyDict_SetItemString(d, "add_triplet", add_triplet);
Py_DECREF(add_triplet);

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;
}
6 changes: 6 additions & 0 deletions 6 numpy/_core/src/umath/_umath_tests.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,11 @@ PyMODINIT_FUNC PyInit__umath_tests(void) {
"cannot load _umath_tests module.");
return NULL;
}

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;
}
2 changes: 2 additions & 0 deletions 2 numpy/f2py/tests/test_abstract_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from numpy.testing import IS_WASM


@pytest.mark.filterwarnings(r"ignore:.*The global interpreter lock \(GIL\) "
r"has been enabled.*:RuntimeWarning")
@pytest.mark.skipif(IS_WASM, reason="Cannot start subprocess")
@pytest.mark.slow
class TestAbstractInterface(util.F2PyTest):
Expand Down
2 changes: 2 additions & 0 deletions 2 numpy/f2py/tests/test_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from . import util


@pytest.mark.filterwarnings(r"ignore:.*The global interpreter lock \(GIL\) "
r"has been enabled.*:RuntimeWarning")
class TestF77Callback(util.F2PyTest):
sources = [util.getpath("tests", "src", "callback", "foo.f")]

Expand Down
5 changes: 5 additions & 0 deletions 5 numpy/fft/_pocketfft_umath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,5 +419,10 @@ PyMODINIT_FUNC PyInit__pocketfft_umath(void)
return NULL;
}

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;
}
5 changes: 5 additions & 0 deletions 5 numpy/linalg/lapack_litemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,5 +409,10 @@ PyMODINIT_FUNC PyInit_lapack_lite(void)
PyDict_SetItemString(d, "_ilp64", Py_False);
#endif

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;
}
5 changes: 5 additions & 0 deletions 5 numpy/linalg/umath_linalg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4699,5 +4699,10 @@ PyMODINIT_FUNC PyInit__umath_linalg(void)
PyDict_SetItemString(d, "_ilp64", Py_False);
#endif

#if Py_GIL_DISABLED
// signal this module supports running with the GIL disabled
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
#endif

return m;
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.