[Python-3000] Free list for small longs
lists at cheimes.de
Thu Feb 7 00:46:02 CET 2008
Martin v. Löwis wrote:
> Both. Let (a,b,c) equal gc.get_threshold(), then a full gc happens
> after a*b*c object allocations (roughly; early object deallocations
> are deducted from that number). Currently, this product is 70000.
I see. 70k is a large number. Do you have some real world experience how
often a a full gc takes place?
> Ain't we talking about Python 3? There aren't any int memory blocks
> around. As for float objects - sure, we should do something about them.
> I propose to change them into a freelist as well, and allocate float
> objects through pymalloc.
I was referring to Python 2.x as well. Your proposed solution would make
it easier to maintain a small free list but it may also make allocation
slower. How old are the int and float blocks? Where they implemented
before Python got pymalloc?
I found another place that may gain some speedup from free lists.
Currently list and dict aren't using a real free list. The code
pre-allocates 80 objects each. I've modified the code to free list
without pre-allocated objects. I also added some debug code to measure
how many objects are reused or allocated:
./python setup build
List allocations: 1046
List reuse through freelist: 15746
Dict allocations: 770
Dict reuse through freelist: 1307
A simple startup of Python
List allocations: 59
List reuse through freelist: 644
Dict allocations: 239
Dict reuse through freelist: 223
More information about the Python-3000