Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83524f6

Browse files
committed
BUG: fix arrays wrapping foreign data losing their alignment flag
e.g. ufunc_at wraps input arrays which without this fix causes the iterator to choose much slower unaligned code paths. Also pointers from malloc can be not aligned for long double types, e.g. on debian sparc.
1 parent fc5d7cf commit 83524f6

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

numpy/core/src/multiarray/ctors.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,12 +1054,12 @@ PyArray_NewFromDescr_int(PyTypeObject *subtype, PyArray_Descr *descr, int nd,
10541054
fa->data = data;
10551055

10561056
/*
1057-
* If the strides were provided to the function, need to
1058-
* update the flags to get the right CONTIGUOUS, ALIGN properties
1057+
* always update the flags to get the right CONTIGUOUS, ALIGN properties
1058+
* not owned data and input strides may not be aligned and on some
1059+
* platforms (debian sparc) malloc does not provide enough alignment for
1060+
* long double types
10591061
*/
1060-
if (strides != NULL) {
1061-
PyArray_UpdateFlags((PyArrayObject *)fa, NPY_ARRAY_UPDATE_ALL);
1062-
}
1062+
PyArray_UpdateFlags((PyArrayObject *)fa, NPY_ARRAY_UPDATE_ALL);
10631063

10641064
/*
10651065
* call the __array_finalize__

0 commit comments

Comments
 (0)