[Python-3000] Free list for small longs
"Martin v. Löwis"
martin at v.loewis.de
Thu Feb 7 06:04:12 CET 2008
>> 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?
Not from a real world application, no. If you run the program below with
python /tmp/a.py 2>&1|grep "generation 2"
you'll see it does one "regular" generation-2-collection; on my machine,
it takes 0.23s for that to happen. Notice that this application doesn't
use reference counting at all (i.e. objects are released here only
through GC, not because their refcount goes zero before the GC
triggers).
What are you aiming at? Is it a good thing or a bad thing that 70k is
a large number?
> 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 don't remember; try to find out for yourself.
I think it will be very difficult to demonstrate that releasing the
freelists has a significant effect when it's run along with GC. The
time for running the GC should dominate the time spend in releasing
the freelists, and any application for which the freelists help (i.e.
which periodically allocate many similar object and then return them)
will rebuild the freelist to the required size quickly.
Regards,
Martin
More information about the Python-3000
mailing list