[Python-Dev] C API for gc.enable() and gc.disable()

"Martin v. Löwis" martin at v.loewis.de
Sat Jun 21 17:20:07 CEST 2008


> Well, they could hang themselves or switch to another language (which
> some people might view as equivalent :-)), but perhaps optimistically
> the various propositions that were sketched out in this thread (by Adam
> Olsen and Greg Ewing) could bring an improvement. I don't know how
> realistic they are, perhaps an expert would have an answer.

In general, any solution of the "do GC less often" needs to deal with
cases where lots of garbage gets produced in a short amount of time
(e.g. in a tight loop), and which run out of memory when GC is done less
often.

Given the choice of "run slower" and "run out of memory", Python should
always prefer the former.

One approach could be to measure how successful a GC run was: if GC
finds that more-and-more objects get allocated and very few (or none)
are garbage, it might conclude that this is an allocation spike, and
back off. The tricky question is how to find out that the spike is
over.

Regards,
Martin


More information about the Python-Dev mailing list