On Feb 6, 12:05 pm, Simon King <[email protected]> wrote: > There is the idea to always keep the last N created parents alive by a > strong reference. Couldn't this easily be done, by appending "self" to a > list (and removing the first entry, when the list is too long), while
Yes, except you want to do it circularly: initialize: keep_alive=[None for i in xrange(cache_length)] and then: keep_alive[n]=new_parent n=(n+1) % len(keep_alive) However, given that parents (or at least the ones we're concerned about) can only be deleted by GC anyway due to the circularities in them, I think you get the same (aggregate) behaviour by tweaking gc.set_threshold: If a lot non-parent memory allocations (without deletes) are happening, parent-related stuff isn't dominant anyway, so recreation doesn't matter. Otherwise, the allocated-object-count is dominated by parent creation anyway, so GC triggers will be roughly every "N" parent allocation. In fact it's better already: If parents are constantly created and left-for-dead then not every GC is problematic: Only the ones that happen to fall in the timespan when there isn't a strong reference to the parent anymore. I think you'll first need to come up with a real-world example that shows truly detrimental effects from not keeping C alive. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
