Message109247
tp_del() is generally invoked by tp_dealloc(). See for example typeobject.c:849. gc.collect() never invokes tp_del() directy, that is left for the objects themselves (as part of tp_dealloc())
Now, gc already knows that if tp_del is present, it cannot cause break the cycle, (for various technical reasons, one of them being that tp_del would be invoked with various dependency objects already nerfed by tp_clear()).
But this is not always enough:
1) it may be too pessimistic. Sometimes the tp_del method doesn't do anything significant, or isn't even called, depending on runtime state, so it is safe for gc to clear the object (see for example genobject.c:30).
2) Sometimes finalization behaviour is not defined by a tp_del method at all, but rather some custom code in tp_dealloc.
All this patch does, is to generalize the mechanism already provided for genobject.c (by PyGen_NeedsFinalizing()), to any object: Any object can signal to gc that: a) it is ok to collect a cycle with me in it, or b) no, it is unsafe to do so. With this patch in place, PyGen_NeedsFinalizing() no longer needs to be a special case in gcmodule.c.
Yes, I'll send a message to python-dev. |
|
Date |
User |
Action |
Args |
2010-07-04 17:56:21 | kristjan.jonsson | set | recipients:
+ kristjan.jonsson, tim.peters, pitrou |
2010-07-04 17:56:21 | kristjan.jonsson | set | messageid: <1278266181.78.0.521399186253.issue9141@psf.upfronthosting.co.za> |
2010-07-04 17:56:20 | kristjan.jonsson | link | issue9141 messages |
2010-07-04 17:56:19 | kristjan.jonsson | create | |
|