diff options
author | Nate Jensen <Nathan.Jensen@raytheon.com> | 2015-07-14 11:45:50 -0500 |
---|---|---|
committer | Nate Jensen <Nathan.Jensen@raytheon.com> | 2015-07-22 15:46:45 -0500 |
commit | 50f1fce49d79444c29d63cd632bbb87ceec39f07 (patch) | |
tree | 8f7f559cbc41c169e686474cc0945a77eb11c5fb /numpy/core | |
parent | 49617ac803dfe6f9542410045854203018602b18 (diff) | |
download | numpy-50f1fce49d79444c29d63cd632bbb87ceec39f07.tar.gz |
ENH skip NPY_ALLOW_C_API for UFUNC_ERR_PRINT
GIL unnecessary when numpy floating point error handling is set to print
potential micro-optimization when error handling is set to print
alleviates (but does not fix) #5856 deadlock with sub-interpreters
addressed comments and initial test failed
Change-Id: I0414df8c5dca131e1f8c8d867791ba63cf992b63
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 804cba65e..779773101 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -105,7 +105,17 @@ _error_handler(int method, PyObject *errobj, char *errtype, int retstatus, int * PyObject *pyfunc, *ret, *args; char *name = PyBytes_AS_STRING(PyTuple_GET_ITEM(errobj,0)); char msg[100]; - NPY_ALLOW_C_API_DEF; + + NPY_ALLOW_C_API_DEF + + /* don't need C API for a simple print */ + if (method == UFUNC_ERR_PRINT) { + if (*first) { + fprintf(stderr, "Warning: %s encountered in %s\n", errtype, name); + *first = 0; + } + return 0; + } NPY_ALLOW_C_API; switch(method) { @@ -140,12 +150,6 @@ _error_handler(int method, PyObject *errobj, char *errtype, int retstatus, int * } Py_DECREF(ret); break; - case UFUNC_ERR_PRINT: - if (*first) { - fprintf(stderr, "Warning: %s encountered in %s\n", errtype, name); - *first = 0; - } - break; case UFUNC_ERR_LOG: if (first) { *first = 0; |