[Python-ideas] Exact integral types in struct

Simon Sapin simon.sapin at kozea.fr
Wed Mar 21 11:14:11 CET 2012


Le 21/03/2012 07:31, Greg Ewing a écrit :
> Serhiy Storchaka wrote:
>
>> >  I think that in the documentation for the struct module should clarify,
>> >  what is the*standard*  size and alignment.
> Yes, it's a bit perplexing the way it casually throws in the
> word "standard" without any elaboration at that point. It leaves
> the reader wondering -- which standard? It sounds like it's
> referring to some widely-recognised standard that the reader is
> assumed to already know about, whereas it's actually something
> made up for the struct module.


I don’t see this problem when reading the documentation. The idea of 
"standard" size is introduced in section 7.3.2.1:

> Standard size depends only on the format character; see the table
> in the Format Characters section.

The said table in the next section has a "Standard size" column. For 
example, the size for "@i" (native size) is variable, but "=i" (standard 
size) is always 4 bytes.

http://docs.python.org/library/struct.html#byte-order-size-and-alignment
http://docs.python.org/library/struct.html#format-characters


Maybe the docs should not use the word "standard". But it is 
self-contained: it does not refer to an external standard.


As to alignment, the table in 7.3.2.1 is pretty clear that "standard 
alignment" is no alignment at all.
-- 
Simon Sapin



More information about the Python-ideas mailing list