Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
704fde7
Update PyBuffer_FromContiguous definition: rename 'fort' parameter to…
CarlosEduR Aug 16, 2025
a892331
Update documentation to reflect change to PyBuffer_FromContiguous
CarlosEduR Aug 16, 2025
4ad032e
Merge branch 'main' into fix-issue-137696
CarlosEduR Aug 16, 2025
9173bf3
gh-137696: update PyBuffer_FillContiguousStrides, rename fort paramet…
CarlosEduR Aug 18, 2025
3de582d
gh-137696: update PyBuffer_FromContiguous documentation to include ca…
CarlosEduR Aug 18, 2025
a56b6e4
Merge branch 'fix-issue-137696' of https://github.com/CarlosEduR/cpyt…
CarlosEduR Aug 18, 2025
505127f
Merge branch 'main' of https://github.com/CarlosEduR/cpython into fix…
CarlosEduR Aug 18, 2025
4181101
Merge branch 'main' of https://github.com/CarlosEduR/cpython into fix…
CarlosEduR Aug 26, 2025
41630cc
Merge branch 'main' of https://github.com/CarlosEduR/cpython into fix…
CarlosEduR Sep 6, 2025
d3441f0
Update PyBuffer_FromContiguous definition: rename 'fort' parameter to…
CarlosEduR Aug 16, 2025
c89a638
Update documentation to reflect change to PyBuffer_FromContiguous
CarlosEduR Aug 16, 2025
295ea6e
gh-137696: update PyBuffer_FillContiguousStrides, rename fort paramet…
CarlosEduR Aug 18, 2025
af5b9d2
gh-137696: update PyBuffer_FromContiguous documentation to include ca…
CarlosEduR Aug 18, 2025
99cf757
Merge branch 'main' of https://github.com/CarlosEduR/cpython into fix…
CarlosEduR Jan 5, 2026
cb11807
use the same wording as PyBuffer_ToContiguous for the order parameter
CarlosEduR Jan 5, 2026
eff990f
use the same wording as PyBuffer_ToContiguous for the order parameter
CarlosEduR Jan 5, 2026
0705d12
remove blank line, following existing pattern
CarlosEduR Jan 5, 2026
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
5 changes: 3 additions & 2 deletions Doc/c-api/buffer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,11 @@ 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'`` or ``'A'`` (for C-style or Fortran-style
ordering or either one).
``0`` is returned on success, ``-1`` on error.


Expand Down
12 changes: 6 additions & 6 deletions Include/pybuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,27 @@ 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,
Py_ssize_t *shape,
Py_ssize_t *strides,
int itemsize,
char fort);
char order);

/* Fills in a buffer-info structure correctly for an exporter
that can only share a contiguous chunk of memory of
Expand Down
10 changes: 5 additions & 5 deletions Objects/abstract.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,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 @@ -636,7 +636,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 @@ -654,7 +654,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 Expand Up @@ -749,13 +749,13 @@ int PyObject_CopyData(PyObject *dest, PyObject *src)
void
PyBuffer_FillContiguousStrides(int nd, Py_ssize_t *shape,
Py_ssize_t *strides, int itemsize,
char fort)
char order)
{
int k;
Py_ssize_t sd;

sd = itemsize;
if (fort == 'F') {
if (order == 'F') {
for (k=0; k<nd; k++) {
strides[k] = sd;
sd *= shape[k];
Expand Down
Loading