array.itemsize: Documentation Versus Reality

Christian Heimes christian at python.org
Sat Sep 17 07:53:28 EDT 2016


On 2016-09-17 05:47, Lawrence D’Oliveiro wrote:
>     >>> a = array.array("I", (0,))
>     >>> a.itemsize
>     4
>     >>> a = array.array("L", (0,))
>     >>> a.itemsize
>     8
> 
> According to <https://docs.python.org/3/library/array.html>, the “minimum size” should be 2 and 4 respectively. It further says:
> 
>     The actual representation of values is determined by the machine
>     architecture (strictly speaking, by the C implementation).
>     The actual size can be accessed through the itemsize attribute.
> 
> Are there any C compilers still in common use where the values will not be 4 and 8, as above?

Yes, on Windows (32 and 64bit), a long is always 32bit and an array with
datatype "L" has itemsize 4.

Christian





More information about the Python-list mailing list