diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-01-24 13:16:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-24 13:16:52 -0800 |
commit | 9b7e890b014f6ad3b4288246f0565f7afd6eca84 (patch) | |
tree | 05b6edb36c9e6efbfac793f5b2b935b7480464cc | |
parent | b5fa3520dd54c211ff938ddfa5d24c46f673b915 (diff) | |
parent | 7e8c0d65958013ac00c2efdfed0a388ac740ac6d (diff) | |
download | numpy-9b7e890b014f6ad3b4288246f0565f7afd6eca84.tar.gz |
Merge pull request #15422 from sethtroisi/buff_cleanup
MAINT: Inline gentype_getreadbuf
-rw-r--r-- | numpy/core/src/multiarray/scalartypes.c.src | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index d23a8ea1a..2bd4cd2ee 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -1551,14 +1551,6 @@ gentype_itemset(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args)) return NULL; } -/* This function matches the Python 2.7 PyBufferProcs.bf_getreadbuffer - * interface, but no longer needs to. In the future we could consider - * rewriting callers to use `gentype_getbuffer`, or inline the function body - * at the caller. - */ -static Py_ssize_t -gentype_getreadbuf(PyObject *, Py_ssize_t, void **); - static PyObject * gentype_byteswap(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1581,8 +1573,9 @@ gentype_byteswap(PyObject *self, PyObject *args, PyObject *kwds) PyObject *new; char *newmem; - gentype_getreadbuf(self, 0, (void **)&data); descr = PyArray_DescrFromScalar(self); + data = (void *)scalar_value(self, descr); + newmem = PyObject_Malloc(descr->elsize); if (newmem == NULL) { Py_DECREF(descr); @@ -2449,31 +2442,6 @@ static PySequenceMethods voidtype_as_sequence = { }; -static Py_ssize_t -gentype_getreadbuf(PyObject *self, Py_ssize_t segment, void **ptrptr) -{ - int numbytes; - PyArray_Descr *outcode; - - if (segment != 0) { - PyErr_SetString(PyExc_SystemError, - "Accessing non-existent array segment"); - return -1; - } - - outcode = PyArray_DescrFromScalar(self); - numbytes = outcode->elsize; - *ptrptr = (void *)scalar_value(self, outcode); - -#ifndef Py_UNICODE_WIDE - if (outcode->type_num == NPY_UNICODE) { - numbytes >>= 1; - } -#endif - Py_DECREF(outcode); - return numbytes; -} - static PyBufferProcs gentype_as_buffer = { gentype_getbuffer, /* bf_getbuffer */ NULL, /* bf_releasebuffer */ |