* This is a strategy to buy a little speed up and avoid the dictionary * look-up in the default case. It should work in the presence of * threads. If it is deemed too complicated or it doesn't actually work * it could be taken out. */
| 25 | * it could be taken out. |
| 26 | */ |
| 27 | NPY_NO_EXPORT int |
| 28 | ufunc_update_use_defaults(void) |
| 29 | { |
| 30 | PyObject *errobj = NULL; |
| 31 | int errmask, bufsize; |
| 32 | int res; |
| 33 | |
| 34 | PyUFunc_NUM_NODEFAULTS += 1; |
| 35 | res = PyUFunc_GetPyValues("test", &bufsize, &errmask, &errobj); |
| 36 | PyUFunc_NUM_NODEFAULTS -= 1; |
| 37 | if (res < 0) { |
| 38 | Py_XDECREF(errobj); |
| 39 | return -1; |
| 40 | } |
| 41 | if ((errmask != UFUNC_ERR_DEFAULT) || (bufsize != NPY_BUFSIZE) |
| 42 | || (PyTuple_GET_ITEM(errobj, 1) != Py_None)) { |
| 43 | PyUFunc_NUM_NODEFAULTS += 1; |
| 44 | } |
| 45 | else if (PyUFunc_NUM_NODEFAULTS > 0) { |
| 46 | PyUFunc_NUM_NODEFAULTS -= 1; |
| 47 | } |
| 48 | Py_XDECREF(errobj); |
| 49 | return 0; |
| 50 | } |
| 51 | #endif |
| 52 | |
| 53 | /* |
no test coverage detected