[Python-Dev] Object free lists

Tim Peters tim.one at comcast.net
Tue Jun 15 23:21:45 EDT 2004


[Bob Ippolito]
> The implementation of malloc in OS X always returns pointers aligned to
> 16-byte boundaries, so that the buffers can be reasonably used by AltiVec
> instructions.  Would there be a difference in this case? :)

The int object free list is carved out of larger contiguous blocks, 12 bytes
(on most boxes) at a time -- see the code for details:

struct _intblock {
	struct _intblock *next;
	PyIntObject objects[N_INTOBJECTS];
};

If we had hidden malloc overhead bytes per object, pymalloc would probably
be more space-efficient than the platform malloc.  If the OS X C compiler
says sizeof(PyIntObject) == 16 (which it may or may not do, independent of
what malloc() likes best), then int objects will indeed consume 16 bytes
apiece despite Python's attempt to be more space-efficient than that.





More information about the Python-Dev mailing list