mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Added q/Q standard (x-platform 8-byte ints) mode in struct module.
This completes the q/Q project. longobject.c _PyLong_AsByteArray: The original code had a gross bug: the most-significant Python digit doesn't necessarily have SHIFT significant bits, and you really need to count how many copies of the sign bit it has else spurious overflow errors result. test_struct.py: This now does exhaustive std q/Q testing at, and on both sides of, all relevant power-of-2 boundaries, both positive and negative. NEWS: Added brief dict news while I was at it.
This commit is contained in:
parent
ac4797a12e
commit
7a3bfc3a47
5 changed files with 337 additions and 77 deletions
|
|
@ -72,7 +72,8 @@ Notes:
|
|||
\item[(1)]
|
||||
The \character{q} and \character{Q} conversion codes are available in
|
||||
native mode only if the platform C compiler supports C \ctype{long long},
|
||||
or, on Windows, \ctype{__int64}.
|
||||
or, on Windows, \ctype{__int64}. They're always available in standard
|
||||
modes.
|
||||
\end{description}
|
||||
|
||||
|
||||
|
|
@ -100,8 +101,8 @@ passed in to \function{pack()} is too long, the stored representation
|
|||
is truncated. If the string is too short, padding is used to ensure
|
||||
that exactly enough bytes are used to satisfy the count.
|
||||
|
||||
For the \character{I} and \character{L} format characters, the return
|
||||
value is a Python long integer.
|
||||
For the \character{I}, \character{L}, \character{q} and \character{Q}
|
||||
format characters, the return value is a Python long integer.
|
||||
|
||||
For the \character{P} format character, the return value is a Python
|
||||
integer or long integer, depending on the size needed to hold a
|
||||
|
|
@ -139,10 +140,12 @@ Native size and alignment are determined using the C compiler's
|
|||
order.
|
||||
|
||||
Standard size and alignment are as follows: no alignment is required
|
||||
for any type (so you have to use pad bytes); \ctype{short} is 2 bytes;
|
||||
\ctype{int} and \ctype{long} are 4 bytes. \ctype{float} and
|
||||
\ctype{double} are 32-bit and 64-bit IEEE floating point numbers,
|
||||
respectively.
|
||||
for any type (so you have to use pad bytes);
|
||||
\ctype{short} is 2 bytes;
|
||||
\ctype{int} and \ctype{long} are 4 bytes;
|
||||
\ctype{long long} (\ctype{__int64} on Windows) is 8 bytes;
|
||||
\ctype{float} and \ctype{double} are 32-bit and 64-bit
|
||||
IEEE floating point numbers, respectively.
|
||||
|
||||
Note the difference between \character{@} and \character{=}: both use
|
||||
native byte order, but the size and alignment of the latter is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue