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

Commit59ec898

Browse files
committed
umath_linalg: attempt opt-out
1 parent6876e24 commit59ec898

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎numpy/linalg/umath_linalg.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4688,12 +4688,22 @@ static PyMethodDef UMath_LinAlgMethods[] = {
46884688
{NULL,NULL,0,NULL}/* Sentinel */
46894689
};
46904690

4691+
staticintmodule_loaded=0;
4692+
46914693
staticint
46924694
_umath_linalg_exec(PyObject*m)
46934695
{
46944696
PyObject*d;
46954697
PyObject*version;
46964698

4699+
// https://docs.python.org/3/howto/isolating-extensions.html#opt-out-limiting-to-one-module-object-per-process
4700+
if (module_loaded) {
4701+
PyErr_SetString(PyExc_ImportError,
4702+
"cannot load module more than once per process");
4703+
return-1;
4704+
}
4705+
module_loaded=1;
4706+
46974707
import_array1(-1);
46984708
import_umath1(-1);
46994709

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp