summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2008-03-22 00:24:21 +0000
committerTravis Oliphant <oliphant@enthought.com>2008-03-22 00:24:21 +0000
commitbe077dafb8ed2b9dc30f925868612cf7d7f56a2b (patch)
tree873a8f04caf03bb57788e95e55370d66c2e4b64c
parent9b9fcfc21898b8b27d28cde951da580ed706c082 (diff)
downloadnumpy-be077dafb8ed2b9dc30f925868612cf7d7f56a2b.tar.gz
More complete fix to #647 so that fast copy is not attempted on portions of record arrays.
-rw-r--r--numpy/core/include/numpy/ndarrayobject.h10
-rw-r--r--numpy/core/src/arrayobject.c13
2 files changed, 14 insertions, 9 deletions
diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h
index 3b1376cd3..ba2bc31a7 100644
--- a/numpy/core/include/numpy/ndarrayobject.h
+++ b/numpy/core/include/numpy/ndarrayobject.h
@@ -1748,6 +1748,16 @@ typedef struct {
#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))
#define PyArray_HASFIELDS(obj) PyDataType_HASFIELDS(PyArray_DESCR(obj))
+ /* FIXME: This should check for a flag on the data-type
+ that states whether or not it is variable length.
+ Because the ISFLEXIBLE check is hard-coded to the
+ built-in data-types.
+ */
+#define PyArray_ISVARIABLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))
+
+#define PyArray_SAFEALIGNEDCOPY(obj) (PyArray_ISALIGNED(obj) && !PyArray_ISVARIABLE(obj))
+
+
#define NPY_LITTLE '<'
#define NPY_BIG '>'
#define NPY_NATIVE '='
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 567aa7750..3e11d3c3a 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -758,12 +758,7 @@ _copy_from0d(PyArrayObject *dest, PyArrayObject *src, int usecopy, int swap)
sptr = aligned;
}
else sptr = src->data;
- /* FIXME: This should check for a flag on the data-type
- that states whether or not it is variable length.
- Because the ISFLEXIBLE check is hard-coded to the
- built-in data-types.
- */
- if (PyArray_ISALIGNED(dest) && !PyArray_ISFLEXIBLE(dest)) {
+ if (PyArray_SAFEALIGNEDCOPY(dest)) {
myfunc = _strided_byte_copy;
}
else if (usecopy) {
@@ -865,7 +860,7 @@ int _flat_copyinto(PyObject *dst, PyObject *src, NPY_ORDER order) {
it = (PyArrayIterObject *)PyArray_IterAllButAxis(src, &axis);
if (it == NULL) return -1;
- if (PyArray_ISALIGNED(src)) {
+ if (PyArray_SAFEALIGNEDCOPY(src)) {
myfunc = _strided_byte_copy;
}
else {
@@ -1061,7 +1056,7 @@ _array_copy_into(PyArrayObject *dest, PyArrayObject *src, int usecopy)
return _copy_from0d(dest, src, usecopy, swap);
}
- if (PyArray_ISALIGNED(dest) && PyArray_ISALIGNED(src)) {
+ if (PyArray_SAFEALIGNEDCOPY(dest) && PyArray_SAFEALIGNEDCOPY(src)) {
myfunc = _strided_byte_copy;
}
else if (usecopy) {
@@ -1127,7 +1122,7 @@ PyArray_CopyAnyInto(PyArrayObject *dest, PyArrayObject *src)
if (PyArray_SAMESHAPE(dest, src)) {
int swap;
- if (PyArray_ISALIGNED(dest) && PyArray_ISALIGNED(src)) {
+ if (PyArray_SAFEALIGNEDCOPY(dest) && PyArray_SAFEALIGNEDCOPY(src)) {
myfunc = _strided_byte_copy;
}
else {