array.itemsize: Documentation Versus Reality

eryk sun eryksun at gmail.com
Sun Sep 18 00:43:48 EDT 2016


On Sun, Sep 18, 2016 at 3:55 AM, Chris Angelico <rosuav at gmail.com> wrote:
> On Sun, Sep 18, 2016 at 1:16 PM, Lawrence D’Oliveiro
> <lawrencedo99 at gmail.com> wrote:
>> On Sunday, September 18, 2016 at 2:34:46 PM UTC+12, eryk sun wrote:
>>> However, I see that MicroPython [1] has been ported to 16-bit
>>> PIC microcontrollers. An int should be 16-bit in that case.
>>>
>>> [1]: https://github.com/micropython/micropython
>>
>> From the readme: “MicroPython implements the entire Python 3.4 syntax...”
>>
>> Darn. I don’t know whether to applaud or grit my teeth...
>
> What do you mean? It's not perfectly up-to-date with respect to
> CPython, but most alternate implementations lag a bit.
>
> However, it doesn't appear to have an 'itemsize' on its array.
>
>>>> a=array.array("l", (0,))
>>>> dir(a)
> ['append', 'extend']
>
> Not sure what that means about its sizes.

MicroPython's array and struct modules use a common mp_binary_get_size function:

https://github.com/micropython/micropython/blob/v1.8.4/py/binary.c#L37

The array module uses native ("@") sizes, so the size of "i" and "I"
is sizeof(int).



More information about the Python-list mailing list