Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
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
4 changes: 2 additions & 2 deletions Doc/c-api/buffer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,10 @@ Buffer-related functions
*indices* must point to an array of ``view->ndim`` indices.


.. c:function:: int PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, Py_ssize_t len, char fort)
.. c:function:: int PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, Py_ssize_t len, char order)

Copy contiguous *len* bytes from *buf* to *view*.
*fort* can be ``'C'`` or ``'F'`` (for C-style or Fortran-style ordering).
*order* can be ``'C'`` or ``'F'`` (for C-style or Fortran-style ordering).
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment of the PyBuffer_FromContiguous explained the case when the order is A. So, I think we should add a line or two to explain that case in the documentation as well.

Copy link
Author

Choose a reason for hiding this comment

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

Documentation updated to include this case.

``0`` is returned on success, ``-1`` on error.


Expand Down
10 changes: 5 additions & 5 deletions Include/pybuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ PyAPI_FUNC(int) PyBuffer_FromContiguous(const Py_buffer *view, const void *buf,
error (i.e. the object does not have a buffer interface or
it is not working).

If fort is 'F', then if the object is multi-dimensional,
If order is 'F', then if the object is multi-dimensional,
then the data will be copied into the array in
Fortran-style (first dimension varies the fastest). If
fort is 'C', then the data will be copied into the array
in C-style (last dimension varies the fastest). If fort
order is 'C', then the data will be copied into the array
in C-style (last dimension varies the fastest). If order
is 'A', then it does not matter and the copy will be made
in whatever way is more efficient. */
PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src);

/* Copy the data from the src buffer to the buffer of destination. */
PyAPI_FUNC(int) PyBuffer_IsContiguous(const Py_buffer *view, char fort);
PyAPI_FUNC(int) PyBuffer_IsContiguous(const Py_buffer *view, char order);

/*Fill the strides array with byte-strides of a contiguous
(Fortran-style if fort is 'F' or C-style otherwise)
(Fortran-style if order is 'F' or C-style otherwise)
array of the given shape with the given number of bytes
per element. */
PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims,
Expand Down
6 changes: 3 additions & 3 deletions Objects/abstract.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ PyBuffer_SizeFromFormat(const char *format)
}

int
PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, Py_ssize_t len, char fort)
PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, Py_ssize_t len, char order)
{
int k;
void (*addone)(int, Py_ssize_t *, const Py_ssize_t *);
Expand All @@ -628,7 +628,7 @@ PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, Py_ssize_t len,
len = view->len;
}

if (PyBuffer_IsContiguous(view, fort)) {
if (PyBuffer_IsContiguous(view, order)) {
/* simplest copy is all that is needed */
memcpy(view->buf, buf, len);
return 0;
Expand All @@ -646,7 +646,7 @@ PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, Py_ssize_t len,
indices[k] = 0;
}

if (fort == 'F') {
if (order == 'F') {
addone = _Py_add_one_to_index_F;
}
else {
Expand Down
Loading