[Python-Dev] int/float freelists vs pymalloc

Andrew MacIntyre andymac at bullseye.apana.org.au
Fri Feb 8 12:53:54 CET 2008

M.-A. Lemburg wrote:
> On 2008-02-07 14:09, Andrew MacIntyre wrote:
>> Probably in response to the same stimulus as Christian it occurred to me
>> that the freelist approach had been adopted long before PyMalloc was
>> enabled as standard (in 2.3), and that much of the performance gains
>> between 2.2 and 2.3 were in fact due to PyMalloc.
> One of the hopes of having a custom allocator for Python was to be
> able to get rid off all free lists. For some reason that never happened.
> Not sure why. People were probably too busy with adding new
> features to the language at the time ;-)

Very probably ;-)

> Something you could try to make PyMalloc perform better for the builtin
> types is to check the actual size of the allocated PyObjects and then
> make sure that PyMalloc uses arenas large enough to hold a good quantity
> of them, e.g. it's possible that the float types fall into the same
> arena as some other type and thus don't have enough "room" to use
> as free list.

Like MvL, I doubt it.  Uncle Timmy did a pretty thorough nose-clean on

However, my tests do show that something is funny with the current
freelist implementation for floats on at least 2 platforms, and that
doing without that sort of optimisation for float objects would likely
not be a hardship with PyMalloc.

Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac at pcug.org.au             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia

More information about the Python-Dev mailing list