diff options
author | Seth Troisi <sethtroisi@google.com> | 2020-01-23 19:10:10 -0800 |
---|---|---|
committer | Seth Troisi <sethtroisi@google.com> | 2020-01-24 11:43:58 -0800 |
commit | 7e8c0d65958013ac00c2efdfed0a388ac740ac6d (patch) | |
tree | a3231f4a3c001333fd5398fc091b80ccbbb8b5ee | |
parent | 68224f43d09393c1981bb83ee3c13a5158d2817c (diff) | |
download | numpy-7e8c0d65958013ac00c2efdfed0a388ac740ac6d.tar.gz |
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 383cef5bd..eb3b00242 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 */ |