Skip to content

Commit

Permalink
python#22613: explain what "buffer" is in the struct documentation (t…
Browse files Browse the repository at this point in the history
…hanks Jacques Ducasse)
  • Loading branch information
birkenfeld committed Oct 31, 2014
1 parent e4196d3 commit f30132f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Doc/library/struct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------

Expand All @@ -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)
Expand Down

0 comments on commit f30132f

Please sign in to comment.