[issue35562] Issue in sizeof() function

2018-12-22 Thread Ammar Askar
Ammar Askar added the comment: Iterating over _fields_ and adding up the sizeof() for each type could be one solution. -- ___ Python tracker ___ _

[issue35562] Issue in sizeof() function

2018-12-22 Thread Amir Aslan Haghrah
Amir Aslan Haghrah added the comment: Thank you for your response. I noticed this issue while working with 'mmap' and memory sharing. As you said I check it in 'C++' and I got the same result for my struct as Python. - I used

[issue35562] Issue in sizeof() function

2018-12-22 Thread Ammar Askar
Ammar Askar added the comment: This has to do with C struct packing and alignment. You are likely on a 64-bit computer and thus your structs are aligned to 8 byte (64 bit) boundaries. https://docs.python.org/2/library/ctypes.html#structure-union-alignment-and-byte-order Create an equivalent

[issue35562] Issue in sizeof() function

2018-12-22 Thread Amir Aslan Haghrah
New submission from Amir Aslan Haghrah : If you define a structure which contains an 'c_int' and a 'c_double' member. Then run the sizeof() function for it you get 16 as result as follows: - from ctypes import c_int from ctypes import c_double from