summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorDavid Warde-Farley <wardefar@iro.umontreal.ca>2011-09-20 16:59:59 -0400
committerDavid Warde-Farley <wardefar@iro.umontreal.ca>2011-09-20 17:06:38 -0400
commit7d6ceb52c040df3f66e49b0ab11ec7b9108266fe (patch)
treeeeb7487e98ff891b8106ab4713ac1385c10e2d15 /numpy/lib
parente6696cb736b05f0bb01fe4baac683746ace63a24 (diff)
downloadnumpy-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.
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/src/_compiled_base.c17
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);