diff options
author | jaimefrio <jaime.frio@gmail.com> | 2014-09-25 00:10:02 -0700 |
---|---|---|
committer | jaimefrio <jaime.frio@gmail.com> | 2014-09-25 18:27:16 -0700 |
commit | 7dc79a7887730606be1936cc3d3230d21b7e6f2e (patch) | |
tree | b1585c4d80136035a0e249c4c16f82124d160ec7 /numpy/lib/src | |
parent | ed9345fc89a9375c98f00f1be64c5bab1fa7475d (diff) | |
download | numpy-7dc79a7887730606be1936cc3d3230d21b7e6f2e.tar.gz |
ENH: Release GIL in `digitize`
Diffstat (limited to 'numpy/lib/src')
-rw-r--r-- | numpy/lib/src/_compiled_base.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/lib/src/_compiled_base.c b/numpy/lib/src/_compiled_base.c index 3b44664b0..daf96a823 100644 --- a/numpy/lib/src/_compiled_base.c +++ b/numpy/lib/src/_compiled_base.c @@ -211,6 +211,7 @@ arr_digitize(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds) PyObject *ret = NULL; npy_intp len_bins; int monotonic, right = 0; + NPY_BEGIN_THREADS_DEF static char *kwlist[] = {"x", "bins", "right", NULL}; @@ -239,8 +240,11 @@ arr_digitize(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds) goto fail; } + NPY_BEGIN_THREADS_THRESHOLDED(len_bins) monotonic = check_array_monotonic((const double *)PyArray_DATA(arr_bins), len_bins); + NPY_END_THREADS + if (monotonic == 0) { PyErr_SetString(PyExc_ValueError, "bins must be monotonically increasing or decreasing"); @@ -281,10 +285,12 @@ arr_digitize(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds) (npy_intp *)PyArray_DATA((PyArrayObject *)ret); npy_intp len_ret = PyArray_SIZE((PyArrayObject *)ret); + NPY_BEGIN_THREADS_THRESHOLDED(len_ret) while (len_ret--) { *ret_data = len_bins - *ret_data; ret_data++; } + NPY_END_THREADS } fail: |