mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
- Issue #10181: New memoryview implementation fixes multiple ownership
and lifetime issues of dynamically allocated Py_buffer members (#9990) as well as crashes (#8305, #7433). Many new features have been added (See whatsnew/3.3), and the documentation has been updated extensively. The ndarray test object from _testbuffer.c implements all aspects of PEP-3118, so further development towards the complete implementation of the PEP can proceed in a test-driven manner. Thanks to Nick Coghlan, Antoine Pitrou and Pauli Virtanen for review and many ideas. - Issue #12834: Fix incorrect results of memoryview.tobytes() for non-contiguous arrays. - Issue #5231: Introduce memoryview.cast() method that allows changing format and shape without making a copy of the underlying memory.
This commit is contained in:
parent
5a3d04623b
commit
9a2d99e28a
24 changed files with 10011 additions and 1171 deletions
|
@ -340,7 +340,7 @@ PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)
|
|||
}
|
||||
|
||||
static int
|
||||
_IsFortranContiguous(Py_buffer *view)
|
||||
_IsFortranContiguous(const Py_buffer *view)
|
||||
{
|
||||
Py_ssize_t sd, dim;
|
||||
int i;
|
||||
|
@ -361,7 +361,7 @@ _IsFortranContiguous(Py_buffer *view)
|
|||
}
|
||||
|
||||
static int
|
||||
_IsCContiguous(Py_buffer *view)
|
||||
_IsCContiguous(const Py_buffer *view)
|
||||
{
|
||||
Py_ssize_t sd, dim;
|
||||
int i;
|
||||
|
@ -382,16 +382,16 @@ _IsCContiguous(Py_buffer *view)
|
|||
}
|
||||
|
||||
int
|
||||
PyBuffer_IsContiguous(Py_buffer *view, char fort)
|
||||
PyBuffer_IsContiguous(const Py_buffer *view, char order)
|
||||
{
|
||||
|
||||
if (view->suboffsets != NULL) return 0;
|
||||
|
||||
if (fort == 'C')
|
||||
if (order == 'C')
|
||||
return _IsCContiguous(view);
|
||||
else if (fort == 'F')
|
||||
else if (order == 'F')
|
||||
return _IsFortranContiguous(view);
|
||||
else if (fort == 'A')
|
||||
else if (order == 'A')
|
||||
return (_IsCContiguous(view) || _IsFortranContiguous(view));
|
||||
return 0;
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ int
|
|||
PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len,
|
||||
int readonly, int flags)
|
||||
{
|
||||
if (view == NULL) return 0;
|
||||
if (view == NULL) return 0; /* XXX why not -1? */
|
||||
if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
|
||||
(readonly == 1)) {
|
||||
PyErr_SetString(PyExc_BufferError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue