[Python-3000] Free list for small longs

Christian Heimes lists at cheimes.de
Tue Feb 5 21:04:25 CET 2008


I've implemented a free list for small long objects with a size of 1 or
-1. I wanted to test how large the malloc overhead is. The result was
astonishing. The free list quadrupled the speed of a simple test:

$ ./python -m timeit "for i in range(100): list(range(1000))"

Without patch:
10 loops, best of 3: 79 msec per loop

With patch:
10 loops, best of 3: 20.8 msec per loop

Since the free list is limited to small longs, it will consume less than
1,5 MB on a 64bit OS and less than 900kb on a 32bit OS in a worst case
scenario (2 * (1<<15) ~ 65k objects with a size of 14 / 22 byte each).

http://bugs.python.org/issue2013

Christian


More information about the Python-3000 mailing list