[Python-checkins] cpython (merge 3.5 -> default): Merge #23756.

stefan.krah python-checkins at python.org
Sat Aug 8 14:34:48 CEST 2015


https://hg.python.org/cpython/rev/c59b2c4f4cac
changeset:   97328:c59b2c4f4cac
parent:      97326:c7c4b8411037
parent:      97327:d1ef54751412
user:        Stefan Krah <skrah at bytereef.org>
date:        Sat Aug 08 14:34:17 2015 +0200
summary:
  Merge #23756.

files:
  Doc/c-api/buffer.rst     |  15 +++++++++------
  Doc/c-api/memoryview.rst |   2 +-
  Doc/glossary.rst         |  18 ++++++++++++++++--
  Doc/library/stdtypes.rst |   8 ++++----
  4 files changed, 30 insertions(+), 13 deletions(-)


diff --git a/Doc/c-api/buffer.rst b/Doc/c-api/buffer.rst
--- a/Doc/c-api/buffer.rst
+++ b/Doc/c-api/buffer.rst
@@ -96,8 +96,8 @@
       block of the exporter. For example, with negative :c:member:`~Py_buffer.strides`
       the value may point to the end of the memory block.
 
-      For contiguous arrays, the value points to the beginning of the memory
-      block.
+      For :term:`contiguous` arrays, the value points to the beginning of
+      the memory block.
 
    .. c:member:: void \*obj
 
@@ -281,11 +281,14 @@
 +-----------------------------+-------+---------+------------+
 
 
+.. index:: contiguous, C-contiguous, Fortran contiguous
+
 contiguity requests
 ~~~~~~~~~~~~~~~~~~~
 
-C or Fortran contiguity can be explicitly requested, with and without stride
-information. Without stride information, the buffer must be C-contiguous.
+C or Fortran :term:`contiguity <contiguous>` can be explicitly requested,
+with and without stride information. Without stride information, the buffer
+must be C-contiguous.
 
 .. tabularcolumns:: |p{0.35\linewidth}|l|l|l|l|
 
@@ -466,13 +469,13 @@
 .. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char order)
 
    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.
 
 
 .. 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
    given shape with the given number of bytes per element.
 
diff --git a/Doc/c-api/memoryview.rst b/Doc/c-api/memoryview.rst
--- a/Doc/c-api/memoryview.rst
+++ b/Doc/c-api/memoryview.rst
@@ -35,7 +35,7 @@
 
 .. 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
    interface. If memory is contiguous, the memoryview object points to the
    original memory. Otherwise, a copy is made and the memoryview points to a
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -109,8 +109,10 @@
          A :term:`text file` reads and writes :class:`str` objects.
 
    bytes-like object
-      An object that supports the :ref:`bufferobjects`, like :class:`bytes`,
-      :class:`bytearray` or :class:`memoryview`.  Bytes-like objects can
+      An object that supports the :ref:`bufferobjects` and 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
       compression, saving to a binary file, and sending over a socket.
 
@@ -169,6 +171,18 @@
       statement by defining :meth:`__enter__` and :meth:`__exit__` methods.
       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
       Coroutines is a more generalized form of subroutines. Subroutines are
       entered at one point and exited at another point.  Coroutines can be
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -3561,7 +3561,7 @@
       Cast a memoryview to a new format or shape. *shape* defaults to
       ``[byte_length//new_itemsize]``, which means that the result view
       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.
 
       The destination format is restricted to a single element native format in
@@ -3752,19 +3752,19 @@
 
    .. 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
 
    .. 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
 
    .. attribute:: contiguous
 
-      A bool indicating whether the memory is contiguous.
+      A bool indicating whether the memory is :term:`contiguous`.
 
       .. versionadded:: 3.3
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list