-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: support no-copy pickling for any array that can be transposed to a C-contiguous array #28105
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
Changes from 1 commit
0dcde49
a27f5eb
50be134
7cea83c
bf5ecaa
a566660
63da2b9
9494672
6b9421a
6ca72f1
0f70349
c045bd9
aa357a9
aee895b
1b2f9d6
4a16cd3
449ea59
f0d528a
a8cc7fc
5f88eb3
4ba4c55
de8899a
4be8c0c
e8ddf99
3ee9178
4783c41
d2a8306
94a297a
e17acbc
7fd5037
16e7067
7982184
d635e65
aaa9b9f
ecb863f
bfbde0e
35ea29f
596db8c
1a82f4e
80ba96d
792468a
c213b37
3174d5e
43e214a
42e1c99
f71549f
d5c2215
8b981dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -1861,7 +1861,7 @@ array_reduce_ex_regular(PyArrayObject *self, int NPY_UNUSED(protocol)) | |||||||
static PyObject * | ||||||||
array_reduce_ex_picklebuffer(PyArrayObject *self, int protocol) | ||||||||
{ | ||||||||
PyObject *numeric_mod = NULL, *from_buffer_func = NULL; | ||||||||
PyObject *from_buffer_func = NULL; | ||||||||
PyObject *picklebuf_class = NULL; | ||||||||
PyObject *buffer = NULL, *transposed_array = NULL; | ||||||||
PyArray_Descr *descr = NULL; | ||||||||
|
@@ -1932,23 +1932,21 @@ array_reduce_ex_picklebuffer(PyArrayObject *self, int protocol) | |||||||
* (gh-12745). | ||||||||
*/ | ||||||||
Py_DECREF(rev_perm); | ||||||||
if (transposed_array != NULL) { | ||||||||
Py_DECREF(transposed_array); | ||||||||
} | ||||||||
PyErr_Clear(); | ||||||||
return array_reduce_ex_regular(self, protocol); | ||||||||
} | ||||||||
|
||||||||
/* Get the _frombuffer() function for reconstruction */ | ||||||||
|
||||||||
numeric_mod = PyImport_ImportModule("numpy._core.numeric"); | ||||||||
if (numeric_mod == NULL) { | ||||||||
Py_DECREF(rev_perm); | ||||||||
Py_DECREF(buffer); | ||||||||
return NULL; | ||||||||
} | ||||||||
from_buffer_func = PyObject_GetAttrString(numeric_mod, "_frombuffer"); | ||||||||
Py_DECREF(numeric_mod); | ||||||||
if (from_buffer_func == NULL) { | ||||||||
if (npy_cache_import_runtime("numpy._core.numeric", "_frombuffer", | ||||||||
&from_buffer_func) == -1) { | ||||||||
Py_DECREF(rev_perm); | ||||||||
Py_DECREF(buffer); | ||||||||
if (transposed_array != NULL) { | ||||||||
Py_DECREF(transposed_array); | ||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This pattern is common enough it has its own macro in the C API. There are some other common operations that have an X variant that does NULL checking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thx, applied |
||||||||
return NULL; | ||||||||
} | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.