[issue3132] implement PEP 3118 struct changes

Mark Dickinson report at bugs.python.org
Thu May 20 19:30:37 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

> For example, I would expect the same padding for 'BT{I}' and 'BI'.

Granted, yes.  But I wouldn't expect the same padding for 'BT{BI}' and 'BBI'.  'BT{BI}' should match a C struct which itself has an embedded struct.  For C, I get the following results on my machine:

#include <stdio.h>

/* corresponds to 'T{BI}' */
typedef struct {
  char y;
  int z;
} A;

/* corresponds to 'BT{BI}' */
typedef struct {
  char x;
  A yz;
} B;

/* corresponds to 'BBI' */
typedef struct {
  char x;
  char y;
  int z;
} C;

int main(void) {
  printf("sizeof(A) = %zu\n", sizeof(A));
  printf("sizeof(B) = %zu\n", sizeof(B));
  printf("sizeof(C) = %zu\n", sizeof(C));
  return 0;
}

/*                                                                               
Results on a (64-bit) OS X 10.6 machine:                                         
                                                                                 
sizeof(A) = 8                                                                    
sizeof(B) = 12                                                                   
sizeof(C) = 8                                                                    
*/

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3132>
_______________________________________


More information about the Python-bugs-list mailing list