[Python-Dev] Calling the GC less often when there are lots of long-lived objects (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Wed Dec 17 23:02:10 CET 2008
- Previous message: [Python-Dev] Calling the GC less often when there are lots of long-lived objects
- Next message: [Python-Dev] Calling the GC less often when there are lots of long-lived objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Antoine Pitrou <solipsis pitrou.net> writes:
We could let the user configure the threshold between the old policy and the new policy. Currently it is hard-wired to a value of 10000 (that is, 10000 long-lived objects tracked by the GC).
I've removed the threshold in the latest patches because it didn't make much sense when a few long-lived objects contained a lot of objects not tracked by the GC.
Another improvement I've included in the latest patches (but which is orthogonal to the algorithmic change) is that simple tuples and even simple dicts are not tracked by the GC if they don't need to. A few examples (gc.is_tracked() is a new function which returns True if an object is tracked by the GC):
import gc gc.istracked(()) False gc.istracked((1,2)) False gc.istracked((1,(2, "a", None))) False gc.istracked((1,(2, "a", None, {}))) True
d = {} gc.istracked(d) False d[1,2] = 3,4 gc.istracked(d) False d[5] = None, "a", (1,2,3) gc.istracked(d) False d[6] = {} gc.istracked(d) True gc.istracked(d[6]) False
Regards
Antoine.
- Previous message: [Python-Dev] Calling the GC less often when there are lots of long-lived objects
- Next message: [Python-Dev] Calling the GC less often when there are lots of long-lived objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]