array and struct 64-bit Linux change in behavior Python 3.7 and 2.7

Chris Clark Chris.Clark at actian.com
Mon Dec 2 12:26:00 EST 2019


Test case:

               import array
               array.array('L', [0])
# x.itemsize == 8  rather than 4

This works fine (returns 4) under Windows Python 3.7.3 64-bit build.

Under Ubuntu; Python 2.7.15rc1, 3.6.5, 3.70b3 64-bit this returns 8. Documentation at https://docs.python.org/3/library/array.html explicitly states 'L' is for size 4.
It impacts all uses types of array (e.g. reading from byte strings).

The struct module is a little different:

import struct
x = struct.pack('L', 0)
# len(x) ===8 rather than 4

This can be worked around by using '=L' - which is not well documented - so this maybe a doc issue.

Wanted to post here for comments before opening a bug at https://bugs.python.org/

Is anyone seeing this under Debian/Ubuntu?


Chris



More information about the Python-list mailing list