Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 2 | :mod:`struct` --- Interpret bytes as packed binary data |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 3 | ========================================================= |
| 4 | |
| 5 | .. module:: struct |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 6 | :synopsis: Interpret bytes as packed binary data. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 7 | |
| 8 | .. index:: |
| 9 | pair: C; structures |
| 10 | triple: packing; binary; data |
| 11 | |
| 12 | This module performs conversions between Python values and C structs represented |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 13 | as Python :class:`bytes` objects. It uses :dfn:`format strings` (explained |
| 14 | below) as compact descriptions of the lay-out of the C structs and the |
| 15 | intended conversion to/from Python values. This can be used in handling |
| 16 | binary data stored in files or from network connections, among other sources. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 17 | |
| 18 | The module defines the following exception and functions: |
| 19 | |
| 20 | |
| 21 | .. exception:: error |
| 22 | |
| 23 | Exception raised on various occasions; argument is a string describing what is |
| 24 | wrong. |
| 25 | |
| 26 | |
| 27 | .. function:: pack(fmt, v1, v2, ...) |
| 28 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 29 | Return a bytes containing the values ``v1, v2, ...`` packed according to the |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 30 | given format. The arguments must match the values required by the format |
| 31 | exactly. |
| 32 | |
| 33 | |
| 34 | .. function:: pack_into(fmt, buffer, offset, v1, v2, ...) |
| 35 | |
| 36 | Pack the values ``v1, v2, ...`` according to the given format, write the packed |
| 37 | bytes into the writable *buffer* starting at *offset*. Note that the offset is |
| 38 | a required argument. |
| 39 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 40 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 41 | .. function:: unpack(fmt, bytes) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 42 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 43 | Unpack the bytes (presumably packed by ``pack(fmt, ...)``) according to the |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 44 | given format. The result is a tuple even if it contains exactly one item. The |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 45 | bytes must contain exactly the amount of data required by the format |
| 46 | (``len(bytes)`` must equal ``calcsize(fmt)``). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 47 | |
| 48 | |
| 49 | .. function:: unpack_from(fmt, buffer[,offset=0]) |
| 50 | |
Benjamin Peterson | e0124bd | 2009-03-09 21:04:33 +0000 | [diff] [blame] | 51 | Unpack the *buffer* according to the given format. The result is a tuple even |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 52 | if it contains exactly one item. The *buffer* must contain at least the amount |
| 53 | of data required by the format (``len(buffer[offset:])`` must be at least |
| 54 | ``calcsize(fmt)``). |
| 55 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 56 | |
| 57 | .. function:: calcsize(fmt) |
| 58 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 59 | Return the size of the struct (and hence of the bytes) corresponding to the |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 60 | given format. |
| 61 | |
| 62 | Format characters have the following meaning; the conversion between C and |
| 63 | Python values should be obvious given their types: |
| 64 | |
| 65 | +--------+-------------------------+--------------------+-------+ |
| 66 | | Format | C Type | Python | Notes | |
| 67 | +========+=========================+====================+=======+ |
| 68 | | ``x`` | pad byte | no value | | |
| 69 | +--------+-------------------------+--------------------+-------+ |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 70 | | ``c`` | :ctype:`char` | bytes of length 1 | | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 71 | +--------+-------------------------+--------------------+-------+ |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 72 | | ``b`` | :ctype:`signed char` | integer | \(1) | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 73 | +--------+-------------------------+--------------------+-------+ |
| 74 | | ``B`` | :ctype:`unsigned char` | integer | | |
| 75 | +--------+-------------------------+--------------------+-------+ |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 76 | | ``?`` | :ctype:`_Bool` | bool | \(2) | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 77 | +--------+-------------------------+--------------------+-------+ |
| 78 | | ``h`` | :ctype:`short` | integer | | |
| 79 | +--------+-------------------------+--------------------+-------+ |
| 80 | | ``H`` | :ctype:`unsigned short` | integer | | |
| 81 | +--------+-------------------------+--------------------+-------+ |
| 82 | | ``i`` | :ctype:`int` | integer | | |
| 83 | +--------+-------------------------+--------------------+-------+ |
Georg Brandl | ba956ae | 2007-11-29 17:24:34 +0000 | [diff] [blame] | 84 | | ``I`` | :ctype:`unsigned int` | integer | | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 85 | +--------+-------------------------+--------------------+-------+ |
| 86 | | ``l`` | :ctype:`long` | integer | | |
| 87 | +--------+-------------------------+--------------------+-------+ |
Georg Brandl | ba956ae | 2007-11-29 17:24:34 +0000 | [diff] [blame] | 88 | | ``L`` | :ctype:`unsigned long` | integer | | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 89 | +--------+-------------------------+--------------------+-------+ |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 90 | | ``q`` | :ctype:`long long` | integer | \(3) | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 91 | +--------+-------------------------+--------------------+-------+ |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 92 | | ``Q`` | :ctype:`unsigned long | integer | \(3) | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 93 | | | long` | | | |
| 94 | +--------+-------------------------+--------------------+-------+ |
| 95 | | ``f`` | :ctype:`float` | float | | |
| 96 | +--------+-------------------------+--------------------+-------+ |
| 97 | | ``d`` | :ctype:`double` | float | | |
| 98 | +--------+-------------------------+--------------------+-------+ |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 99 | | ``s`` | :ctype:`char[]` | bytes | \(1) | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 100 | +--------+-------------------------+--------------------+-------+ |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 101 | | ``p`` | :ctype:`char[]` | bytes | \(1) | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 102 | +--------+-------------------------+--------------------+-------+ |
| 103 | | ``P`` | :ctype:`void \*` | integer | | |
| 104 | +--------+-------------------------+--------------------+-------+ |
| 105 | |
| 106 | Notes: |
| 107 | |
| 108 | (1) |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 109 | The ``c``, ``s`` and ``p`` conversion codes operate on :class:`bytes` |
| 110 | objects, but packing with such codes also supports :class:`str` objects, |
| 111 | which are encoded using UTF-8. |
| 112 | |
| 113 | (2) |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 114 | The ``'?'`` conversion code corresponds to the :ctype:`_Bool` type defined by |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 115 | C99. If this type is not available, it is simulated using a :ctype:`char`. In |
| 116 | standard mode, it is always represented by one byte. |
| 117 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 118 | (3) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 119 | The ``'q'`` and ``'Q'`` conversion codes are available in native mode only if |
| 120 | the platform C compiler supports C :ctype:`long long`, or, on Windows, |
| 121 | :ctype:`__int64`. They are always available in standard modes. |
| 122 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 123 | A format character may be preceded by an integral repeat count. For example, |
| 124 | the format string ``'4h'`` means exactly the same as ``'hhhh'``. |
| 125 | |
| 126 | Whitespace characters between formats are ignored; a count and its format must |
| 127 | not contain whitespace though. |
| 128 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 129 | For the ``'s'`` format character, the count is interpreted as the length of the |
| 130 | bytes, not a repeat count like for the other format characters; for example, |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 131 | ``'10s'`` means a single 10-byte string, while ``'10c'`` means 10 characters. |
| 132 | For packing, the string is truncated or padded with null bytes as appropriate to |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 133 | make it fit. For unpacking, the resulting bytes object always has exactly the |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 134 | specified number of bytes. As a special case, ``'0s'`` means a single, empty |
| 135 | string (while ``'0c'`` means 0 characters). |
| 136 | |
Mark Dickinson | b40b947 | 2009-03-29 16:58:21 +0000 | [diff] [blame] | 137 | When packing a value ``x`` using one of the integer formats (``'b'``, |
| 138 | ``'B'``, ``'h'``, ``'H'``, ``'i'``, ``'I'``, ``'l'``, ``'L'``, |
| 139 | ``'q'``, ``'Q'``), if ``x`` is outside the valid range for that format |
| 140 | then :exc:`struct.error` is raised. |
| 141 | |
| 142 | .. versionchanged:: 3.1 |
| 143 | In 3.0, some of the integer formats wrapped out-of-range values and |
| 144 | raised :exc:`DeprecationWarning` instead of :exc:`struct.error`. |
| 145 | |
| 146 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 147 | The ``'p'`` format character encodes a "Pascal string", meaning a short |
| 148 | variable-length string stored in a fixed number of bytes. The count is the total |
| 149 | number of bytes stored. The first byte stored is the length of the string, or |
| 150 | 255, whichever is smaller. The bytes of the string follow. If the string |
| 151 | passed in to :func:`pack` is too long (longer than the count minus 1), only the |
| 152 | leading count-1 bytes of the string are stored. If the string is shorter than |
| 153 | count-1, it is padded with null bytes so that exactly count bytes in all are |
| 154 | used. Note that for :func:`unpack`, the ``'p'`` format character consumes count |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 155 | bytes, but that the string returned can never contain more than 255 bytes. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 156 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 157 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 158 | |
Christian Heimes | dd15f6c | 2008-03-16 00:07:10 +0000 | [diff] [blame] | 159 | For the ``'?'`` format character, the return value is either :const:`True` or |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 160 | :const:`False`. When packing, the truth value of the argument object is used. |
| 161 | Either 0 or 1 in the native or standard bool representation will be packed, and |
| 162 | any non-zero value will be True when unpacking. |
| 163 | |
| 164 | By default, C numbers are represented in the machine's native format and byte |
| 165 | order, and properly aligned by skipping pad bytes if necessary (according to the |
| 166 | rules used by the C compiler). |
| 167 | |
| 168 | Alternatively, the first character of the format string can be used to indicate |
| 169 | the byte order, size and alignment of the packed data, according to the |
| 170 | following table: |
| 171 | |
| 172 | +-----------+------------------------+--------------------+ |
| 173 | | Character | Byte order | Size and alignment | |
| 174 | +===========+========================+====================+ |
| 175 | | ``@`` | native | native | |
| 176 | +-----------+------------------------+--------------------+ |
| 177 | | ``=`` | native | standard | |
| 178 | +-----------+------------------------+--------------------+ |
| 179 | | ``<`` | little-endian | standard | |
| 180 | +-----------+------------------------+--------------------+ |
| 181 | | ``>`` | big-endian | standard | |
| 182 | +-----------+------------------------+--------------------+ |
| 183 | | ``!`` | network (= big-endian) | standard | |
| 184 | +-----------+------------------------+--------------------+ |
| 185 | |
| 186 | If the first character is not one of these, ``'@'`` is assumed. |
| 187 | |
| 188 | Native byte order is big-endian or little-endian, depending on the host system. |
| 189 | For example, Motorola and Sun processors are big-endian; Intel and DEC |
| 190 | processors are little-endian. |
| 191 | |
| 192 | Native size and alignment are determined using the C compiler's |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 193 | ``sizeof`` expression. This is always combined with native byte order. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 194 | |
| 195 | Standard size and alignment are as follows: no alignment is required for any |
| 196 | type (so you have to use pad bytes); :ctype:`short` is 2 bytes; :ctype:`int` and |
| 197 | :ctype:`long` are 4 bytes; :ctype:`long long` (:ctype:`__int64` on Windows) is 8 |
| 198 | bytes; :ctype:`float` and :ctype:`double` are 32-bit and 64-bit IEEE floating |
| 199 | point numbers, respectively. :ctype:`_Bool` is 1 byte. |
| 200 | |
| 201 | Note the difference between ``'@'`` and ``'='``: both use native byte order, but |
| 202 | the size and alignment of the latter is standardized. |
| 203 | |
| 204 | The form ``'!'`` is available for those poor souls who claim they can't remember |
| 205 | whether network byte order is big-endian or little-endian. |
| 206 | |
| 207 | There is no way to indicate non-native byte order (force byte-swapping); use the |
| 208 | appropriate choice of ``'<'`` or ``'>'``. |
| 209 | |
| 210 | The ``'P'`` format character is only available for the native byte ordering |
| 211 | (selected as the default or with the ``'@'`` byte order character). The byte |
| 212 | order character ``'='`` chooses to use little- or big-endian ordering based on |
| 213 | the host system. The struct module does not interpret this as native ordering, |
| 214 | so the ``'P'`` format is not available. |
| 215 | |
| 216 | Examples (all using native byte order, size and alignment, on a big-endian |
| 217 | machine):: |
| 218 | |
| 219 | >>> from struct import * |
| 220 | >>> pack('hhl', 1, 2, 3) |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 221 | b'\x00\x01\x00\x02\x00\x00\x00\x03' |
| 222 | >>> unpack('hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03') |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 223 | (1, 2, 3) |
| 224 | >>> calcsize('hhl') |
| 225 | 8 |
| 226 | |
| 227 | Hint: to align the end of a structure to the alignment requirement of a |
| 228 | particular type, end the format with the code for that type with a repeat count |
| 229 | of zero. For example, the format ``'llh0l'`` specifies two pad bytes at the |
| 230 | end, assuming longs are aligned on 4-byte boundaries. This only works when |
| 231 | native size and alignment are in effect; standard size and alignment does not |
| 232 | enforce any alignment. |
| 233 | |
Benjamin Peterson | 2b7411d | 2008-05-26 17:36:47 +0000 | [diff] [blame] | 234 | Unpacked fields can be named by assigning them to variables or by wrapping |
| 235 | the result in a named tuple:: |
| 236 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 237 | >>> record = b'raymond \x32\x12\x08\x01\x08' |
Benjamin Peterson | 2b7411d | 2008-05-26 17:36:47 +0000 | [diff] [blame] | 238 | >>> name, serialnum, school, gradelevel = unpack('<10sHHb', record) |
| 239 | |
| 240 | >>> from collections import namedtuple |
| 241 | >>> Student = namedtuple('Student', 'name serialnum school gradelevel') |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 242 | >>> Student._make(unpack('<10sHHb', record)) |
| 243 | Student(name=b'raymond ', serialnum=4658, school=264, gradelevel=8) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 244 | |
| 245 | .. seealso:: |
| 246 | |
| 247 | Module :mod:`array` |
| 248 | Packed binary storage of homogeneous data. |
| 249 | |
| 250 | Module :mod:`xdrlib` |
| 251 | Packing and unpacking of XDR data. |
| 252 | |
| 253 | |
| 254 | .. _struct-objects: |
| 255 | |
| 256 | Struct Objects |
| 257 | -------------- |
| 258 | |
| 259 | The :mod:`struct` module also defines the following type: |
| 260 | |
| 261 | |
| 262 | .. class:: Struct(format) |
| 263 | |
| 264 | Return a new Struct object which writes and reads binary data according to the |
| 265 | format string *format*. Creating a Struct object once and calling its methods |
| 266 | is more efficient than calling the :mod:`struct` functions with the same format |
| 267 | since the format string only needs to be compiled once. |
| 268 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 269 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 270 | Compiled Struct objects support the following methods and attributes: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 271 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 272 | .. method:: pack(v1, v2, ...) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 273 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 274 | Identical to the :func:`pack` function, using the compiled format. |
| 275 | (``len(result)`` will equal :attr:`self.size`.) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 276 | |
| 277 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 278 | .. method:: pack_into(buffer, offset, v1, v2, ...) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 279 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 280 | Identical to the :func:`pack_into` function, using the compiled format. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 281 | |
| 282 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 283 | .. method:: unpack(bytes) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 284 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 285 | Identical to the :func:`unpack` function, using the compiled format. |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 286 | (``len(bytes)`` must equal :attr:`self.size`). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 287 | |
| 288 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 289 | .. method:: unpack_from(buffer[, offset=0]) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 290 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 291 | Identical to the :func:`unpack_from` function, using the compiled format. |
| 292 | (``len(buffer[offset:])`` must be at least :attr:`self.size`). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 293 | |
| 294 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 295 | .. attribute:: format |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 296 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 297 | The format string used to construct this Struct object. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 298 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 299 | .. attribute:: size |
Guido van Rossum | 04110fb | 2007-08-24 16:32:05 +0000 | [diff] [blame] | 300 | |
Benjamin Peterson | 4ae1946 | 2008-07-31 15:03:40 +0000 | [diff] [blame] | 301 | The calculated size of the struct (and hence of the bytes) corresponding |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 302 | to :attr:`format`. |
Guido van Rossum | 04110fb | 2007-08-24 16:32:05 +0000 | [diff] [blame] | 303 | |