Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
70e543b2
Commit
70e543b2
authored
Aug 08, 2015
by
Stefan Krah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23756: Clarify the terms "contiguous" and "bytes-like object".
Patch by Martin Panter.
parent
0c51595a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
13 deletions
+30
-13
Doc/c-api/buffer.rst
Doc/c-api/buffer.rst
+9
-6
Doc/c-api/memoryview.rst
Doc/c-api/memoryview.rst
+1
-1
Doc/glossary.rst
Doc/glossary.rst
+16
-2
Doc/library/stdtypes.rst
Doc/library/stdtypes.rst
+4
-4
No files found.
Doc/c-api/buffer.rst
View file @
70e543b2
...
@@ -96,8 +96,8 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
...
@@ -96,8 +96,8 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
block of the exporter. For example, with negative :c:member:`~Py_buffer.strides`
block of the exporter. For example, with negative :c:member:`~Py_buffer.strides`
the value may point to the end of the memory block.
the value may point to the end of the memory block.
For
contiguous arrays, the value points to the beginning of the memory
For
:term:`contiguous` arrays, the value points to the beginning of
block.
the memory
block.
.. c:member:: void \*obj
.. c:member:: void \*obj
...
@@ -281,11 +281,14 @@ of the flags below it.
...
@@ -281,11 +281,14 @@ of the flags below it.
+-----------------------------+-------+---------+------------+
+-----------------------------+-------+---------+------------+
.. index:: contiguous, C-contiguous, Fortran contiguous
contiguity requests
contiguity requests
~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~
C or Fortran contiguity can be explicitly requested, with and without stride
C or Fortran :term:`contiguity <contiguous>` can be explicitly requested,
information. Without stride information, the buffer must be C-contiguous.
with and without stride information. Without stride information, the buffer
must be C-contiguous.
.. tabularcolumns:: |p{0.35\linewidth}|l|l|l|l|
.. tabularcolumns:: |p{0.35\linewidth}|l|l|l|l|
...
@@ -466,13 +469,13 @@ Buffer-related functions
...
@@ -466,13 +469,13 @@ Buffer-related functions
.. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char order)
.. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char order)
Return 1 if the memory defined by the *view* is C-style (*order* is
Return 1 if the memory defined by the *view* is C-style (*order* is
``'C'``) or Fortran-style (*order* is ``'F'``)
contiguous
or either one
``'C'``) or Fortran-style (*order* is ``'F'``)
:term:`contiguous`
or either one
(*order* is ``'A'``). Return 0 otherwise.
(*order* is ``'A'``). Return 0 otherwise.
.. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char order)
.. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char order)
Fill the *strides* array with byte-strides of a
contiguous
(C-style if
Fill the *strides* array with byte-strides of a
:term:`contiguous`
(C-style if
*order* is ``'C'`` or Fortran-style if *order* is ``'F'``) array of the
*order* is ``'C'`` or Fortran-style if *order* is ``'F'``) array of the
given shape with the given number of bytes per element.
given shape with the given number of bytes per element.
...
...
Doc/c-api/memoryview.rst
View file @
70e543b2
...
@@ -35,7 +35,7 @@ any other object.
...
@@ -35,7 +35,7 @@ any other object.
.. c:function:: PyObject *PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order)
.. c:function:: PyObject *PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order)
Create a memoryview object to a
contiguous
chunk of memory (in either
Create a memoryview object to a
:term:`contiguous`
chunk of memory (in either
'C' or 'F'ortran *order*) from an object that defines the buffer
'C' or 'F'ortran *order*) from an object that defines the buffer
interface. If memory is contiguous, the memoryview object points to the
interface. If memory is contiguous, the memoryview object points to the
original memory. Otherwise, a copy is made and the memoryview points to a
original memory. Otherwise, a copy is made and the memoryview points to a
...
...
Doc/glossary.rst
View file @
70e543b2
...
@@ -109,8 +109,10 @@ Glossary
...
@@ -109,8 +109,10 @@ Glossary
A :term:`text file` reads and writes :class:`str` objects.
A :term:`text file` reads and writes :class:`str` objects.
bytes-like object
bytes-like object
An object that supports the :ref:`bufferobjects`, like :class:`bytes`,
An object that supports the :ref:`bufferobjects` and can
:class:`bytearray` or :class:`memoryview`. Bytes-like objects can
export a C-:term:`contiguous` buffer. This includes all :class:`bytes`,
:class:`bytearray`, and :class:`array.array` objects, as well as many
common :class:`memoryview` objects. Bytes-like objects can
be used for various operations that work with binary data; these include
be used for various operations that work with binary data; these include
compression, saving to a binary file, and sending over a socket.
compression, saving to a binary file, and sending over a socket.
...
@@ -169,6 +171,18 @@ Glossary
...
@@ -169,6 +171,18 @@ Glossary
statement by defining :meth:`__enter__` and :meth:`__exit__` methods.
statement by defining :meth:`__enter__` and :meth:`__exit__` methods.
See :pep:`343`.
See :pep:`343`.
contiguous
.. index:: C-contiguous, Fortran contiguous
A buffer is considered contiguous exactly if it is either
*C-contiguous* or *Fortran contiguous*. Zero-dimensional buffers are
C and Fortran contiguous. In one-dimensional arrays, the items
must be layed out in memory next to each other, in order of
increasing indexes starting from zero. In multidimensional
C-contiguous arrays, the last index varies the fastest when
visiting items in order of memory address. However, in
Fortran contiguous arrays, the first index varies the fastest.
coroutine
coroutine
Coroutines is a more generalized form of subroutines. Subroutines are
Coroutines is a more generalized form of subroutines. Subroutines are
entered at one point and exited at another point. Coroutines can be
entered at one point and exited at another point. Coroutines can be
...
...
Doc/library/stdtypes.rst
View file @
70e543b2
...
@@ -3561,7 +3561,7 @@ copying.
...
@@ -3561,7 +3561,7 @@ copying.
Cast a memoryview to a new format or shape. *shape* defaults to
Cast a memoryview to a new format or shape. *shape* defaults to
``[byte_length//new_itemsize]``, which means that the result view
``[byte_length//new_itemsize]``, which means that the result view
will be one-dimensional. The return value is a new memoryview, but
will be one-dimensional. The return value is a new memoryview, but
the buffer itself is not copied. Supported casts are 1D -> C-
contiguous
the buffer itself is not copied. Supported casts are 1D -> C-
:term:`contiguous`
and C-contiguous -> 1D.
and C-contiguous -> 1D.
The destination format is restricted to a single element native format in
The destination format is restricted to a single element native format in
...
@@ -3752,19 +3752,19 @@ copying.
...
@@ -3752,19 +3752,19 @@ copying.
.. attribute:: c_contiguous
.. attribute:: c_contiguous
A bool indicating whether the memory is C-
contiguous
.
A bool indicating whether the memory is C-
:term:`contiguous`
.
.. versionadded:: 3.3
.. versionadded:: 3.3
.. attribute:: f_contiguous
.. attribute:: f_contiguous
A bool indicating whether the memory is Fortran
contiguous
.
A bool indicating whether the memory is Fortran
:term:`contiguous`
.
.. versionadded:: 3.3
.. versionadded:: 3.3
.. attribute:: contiguous
.. attribute:: contiguous
A bool indicating whether the memory is
contiguous
.
A bool indicating whether the memory is
:term:`contiguous`
.
.. versionadded:: 3.3
.. versionadded:: 3.3
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment