• Guido van Rossum's avatar
    Christian Tismer -- total rewrite on trashcan code. · e92e610a
    Guido van Rossum yazdı
    Improvements:
    - does no longer need any extra memory
    - has no relationship to tstate
    - works in debug mode
    - can easily be modified for free threading (hi Greg:)
    
    Side effects:
    Trashcan does change the order of object destruction.
    Prevending that would be quite an immense effort, as
    my attempts have shown. This version works always
    the same, with debug mode or not. The slightly
    changed destruction order should therefore be no problem.
    
    Algorithm:
    While the old idea of delaying the destruction of some
    obejcts at a certain recursion level was kept, we now
    no longer aloocate an object to hold these objects.
    The delayed objects are instead chained together
    via their ob_type field. The type is encoded via
    ob_refcnt. When it comes to the destruction of the
    chain of waiting objects, the topmost object is popped
    off the chain and revived with type and refcount 1,
    then it gets a normal Py_DECREF.
    
    I am confident that this solution is near optimum
    for minimizing side effects and code bloat.
    e92e610a
object.h 19.7 KB