8000 don't copy data when changing shape by tecki · Pull Request #145 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

don't copy data when changing shape #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use PyArray_Newshape instead of PyArray_Reshape
as per the comment in shape.c, the use of PyArray_Reshape is not
recommended. Change set_shape accordingly in getset.c.
  • Loading branch information
tecki committed Aug 24, 2011
commit 96c3bb207586690331ba056511b5f5480e66b7a5
8 changes: 7 additions & 1 deletion numpy/core/src/multiarray/getset.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ array_shape_set(PyArrayObject *self, PyObject *val)
{
int nd;
PyArrayObject *ret;
PyArray_Dims newdims;

/* Assumes C-order */
ret = (PyArrayObject *)PyArray_Reshape(self, val);
if (!PyArray_IntpConverter(val, &newdims)) {
return -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation. Are you using tabs by any chance? Wrong indent setting?

}
ret = (PyArrayObject *)PyArray_Newshape(self, &newdims, PyArray_CORDER);
PyDimMem_FREE(newdims.ptr);

if (ret == NULL) {
return -1;
}
Expand Down
0