summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-10-29 12:12:13 -0500
committerGitHub <noreply@github.com>2018-10-29 12:12:13 -0500
commit0dc45ecc707766c6983eae9b65e2bf518c487dc7 (patch)
tree1eb6bb2843660e48c6f6d9788a4bc40684045558
parentdd14431323fdca18d76ee1b99a28d8e2308abea5 (diff)
parent5ec252bbee0a643cf2c2f1877fbd8a2c83f1c641 (diff)
downloadnumpy-0dc45ecc707766c6983eae9b65e2bf518c487dc7.tar.gz
Merge pull request #12285 from seibert/take_perf
ENH: array does not need to be writable to use as input to take
-rw-r--r--doc/release/1.16.0-notes.rst5
-rw-r--r--numpy/core/src/multiarray/item_selection.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/doc/release/1.16.0-notes.rst b/doc/release/1.16.0-notes.rst
index a0613f61d..a5aa78740 100644
--- a/doc/release/1.16.0-notes.rst
+++ b/doc/release/1.16.0-notes.rst
@@ -262,6 +262,11 @@ copying the data directly into the appropriate slice of the resulting array.
This results in significant speedups for these large arrays, particularly for
arrays being blocked along more than 2 dimensions.
+Speedup ``np.take`` for read-only arrays
+----------------------------------------
+The implementation of ``np.take`` no longer makes an unnecessary copy of the
+source array when its ``writeable`` flag is set to ``False``.
+
Changes
=======
diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c
index de54ca1b3..a7c6b14f4 100644
--- a/numpy/core/src/multiarray/item_selection.c
+++ b/numpy/core/src/multiarray/item_selection.c
@@ -45,7 +45,7 @@ PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int axis,
indices = NULL;
self = (PyArrayObject *)PyArray_CheckAxis(self0, &axis,
- NPY_ARRAY_CARRAY);
+ NPY_ARRAY_CARRAY_RO);
if (self == NULL) {
return NULL;
}