diff options
author | Georg Brandl <georg@python.org> | 2014-10-31 08:46:41 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-10-31 08:46:41 (GMT) |
commit | f30132fdc965967ec5e310fe5154f778791c82aa (patch) | |
tree | 8961dc9ba4ac07f792e2c2db7abbca79231c70e2 | |
parent | e4196d3f2e3a8f30072029084f4b25577b1d84aa (diff) | |
download | cpython-f30132fdc965967ec5e310fe5154f778791c82aa.zip cpython-f30132fdc965967ec5e310fe5154f778791c82aa.tar.gz cpython-f30132fdc965967ec5e310fe5154f778791c82aa.tar.bz2 |
#22613: explain what "buffer" is in the struct documentation (thanks Jacques Ducasse)
-rw-r--r-- | Doc/library/struct.rst | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst index ec2e1be..12d4fbc 100644 --- a/Doc/library/struct.rst +++ b/Doc/library/struct.rst @@ -24,6 +24,14 @@ structs and the intended conversion to/from Python values. or omit implicit pad bytes, use ``standard`` size and alignment instead of ``native`` size and alignment: see :ref:`struct-alignment` for details. +Several :mod:`struct` functions (and methods of :class:`Struct`) take a *buffer* +argument. This refers to objects that implement the :ref:`bufferobjects` and +provide either a readable or read-writable buffer. The most common types used +for that purpose are :class:`bytes` and :class:`bytearray`, but many other types +that can be viewed as an array of bytes implement the buffer protocol, so that +they can be read/filled without additional copying from a :class:`bytes` object. + + Functions and Exceptions ------------------------ @@ -47,7 +55,7 @@ The module defines the following exception and functions: Pack the values *v1*, *v2*, ... according to the format string *fmt* and write the packed bytes into the writable buffer *buffer* starting at - position *offset*. Note that *offset* is a required argument. + position *offset*. Note that *offset* is a required argument. .. function:: unpack(fmt, buffer) |