[Python-Dev] int/float freelists vs pymalloc

Christian Heimes lists at cheimes.de
Mon Feb 11 02:48:38 CET 2008


Andrew MacIntyre wrote:
> I tried a LIFO stack implementation (though I won't claim to have done it
> well), and found it slightly slower than no freelist at all. The
> advantage of such an approach is that the known size of the stack makes
> deallocating excess objects easy (and thus no need for
> sys.compact_free_list() ).

I've tried a single linked free list myself. I used the ob_type field to
daisy chain the int and float objects. Although the code was fairly
short it was slightly slower than an attempt without a free list at all.
pymalloc is fast. It's very hard to beat it though.

A fixed size LIFO array like PyFloatObject
*free_list[PyFloat_MAXFREELIST] increased the speed slightly. IMHO a
value of about 80-200 floats and ints is realistic for most apps. More
objects in the free lists could keep too many pymalloced areas occupied.

Christian



More information about the Python-Dev mailing list