On 2016-08-30 01:14, Brett Cannon wrote: > So the struct in question can be found at > https://github.com/python/cpython/blob/2d264235f6e066611b412f7c2e1603866e0f7f1b/Include/code.h#L10 > . > The official docs say the fields can be changed at any time, so > re-arranging them shouldn't break any ABI compatibility promises: > https://docs.python.org/3/c-api/code.html#c.PyCodeObject . Would > grouping all the fields of the same type together, sorting them by > individual field size (i.e. PyObject*, void*, int, unsigned char*), and > then adding the co_extra field at the end of the grouping of PyObject * > fields do what you're suggesting?
You don't have to resort them all, just move co_firstlineno after co_flags, so all int fields are together. Pointers are typically alignment to multiple of 64 on a 64bit machine. In its current shape PyCodeObject is padded with two unused areas of 32bit: 5 * int32 + 32 bits of padding, 9 * pointers (64 bits each), 1 * int32 + another 32 bits of padding, 3 * pointers. When you move co_firstlineno, you fill in the gap. Christian _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com