summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorRonan Lamy <Ronan.Lamy@normalesup.org>2012-08-03 03:44:47 +0100
committerRonan Lamy <Ronan.Lamy@normalesup.org>2012-08-03 03:47:14 +0100
commitd1839283a2b0b393096cf6bda9b386ea5809d4b0 (patch)
treee7eb1e51a5adc6ae20f9484357ddb8545f77c00f /numpy
parent339c35f30a0a3b52b13980dabb8eeda9602b686f (diff)
downloadnumpy-d1839283a2b0b393096cf6bda9b386ea5809d4b0.tar.gz
Re-enable unpickling optimization for large py3k bytes objects.
Mutating a bytes object is theoretically unsafe, but doesn't cause any problem in any existing version of CPython.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/methods.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
index 119056c56..5ad4f2fd6 100644
--- a/numpy/core/src/multiarray/methods.c
+++ b/numpy/core/src/multiarray/methods.c
@@ -1587,8 +1587,9 @@ array_setstate(PyArrayObject *self, PyObject *args)
/* Check that the string is not interned */
if (!_IsAligned(self) || swap || PyString_CHECK_INTERNED(rawdata)) {
#else
- /* Bytes must always be considered immutable */
- if (1) {
+ /* Bytes should always be considered immutable, but we just grab the
+ * pointer if they are large, to save memory. */
+ if (!_IsAligned(self) || swap || (len <= 1000)) {
#endif
npy_intp num = PyArray_NBYTES(self);
fa->data = PyDataMem_NEW(num);