diff options
author | David Warde-Farley <wardefar@iro.umontreal.ca> | 2011-09-20 16:59:59 -0400 |
---|---|---|
committer | David Warde-Farley <wardefar@iro.umontreal.ca> | 2011-09-20 17:06:38 -0400 |
commit | 7d6ceb52c040df3f66e49b0ab11ec7b9108266fe (patch) | |
tree | eeb7487e98ff891b8106ab4713ac1385c10e2d15 | |
parent | e6696cb736b05f0bb01fe4baac683746ace63a24 (diff) | |
download | numpy-7d6ceb52c040df3f66e49b0ab11ec7b9108266fe.tar.gz |
ENH: release the GIL for arr_insert inner loop.
Releases it only conditionally, as object arrays require refcounting to
be performed within the inner loop, making GIL release impractical.
-rw-r--r-- | numpy/lib/src/_compiled_base.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/numpy/lib/src/_compiled_base.c b/numpy/lib/src/_compiled_base.c index 715656aff..57a641b8c 100644 --- a/numpy/lib/src/_compiled_base.c +++ b/numpy/lib/src/_compiled_base.c @@ -440,9 +440,20 @@ arr_insert(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict) copied = 0; instrides = PyArray_STRIDES(ainput); inshape = PyArray_DIMS(ainput); - arr_insert_loop(mptr, vptr, input_data, zero, PyArray_DATA(avals), - melsize, delsize, objarray, totmask, numvals, nd, - instrides, inshape); + if (objarray) { + /* object array, need to refcount, can't release the GIL */ + arr_insert_loop(mptr, vptr, input_data, zero, PyArray_DATA(avals), + melsize, delsize, objarray, totmask, numvals, nd, + instrides, inshape); + } + else { + /* No increfs take place in arr_insert_loop, so release the GIL */ + NPY_BEGIN_ALLOW_THREADS; + arr_insert_loop(mptr, vptr, input_data, zero, PyArray_DATA(avals), + melsize, delsize, objarray, totmask, numvals, nd, + instrides, inshape); + NPY_END_ALLOW_THREADS; + } Py_DECREF(amask); Py_DECREF(avals); |