]> granicus.if.org Git - python/commit
Christian Tismer -- total rewrite on trashcan code.
authorGuido van Rossum <guido@python.org>
Mon, 24 Apr 2000 15:40:53 +0000 (15:40 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 24 Apr 2000 15:40:53 +0000 (15:40 +0000)
commite92e610a9e0ec78bf9dd4965b980f1b57eeb040e
tree460bc78b7e874de9aa11d45f14f3414a90488ab3
parentdb575db0d6503a8acdb0f56ce74a339bf63c9a08
Christian Tismer -- total rewrite on trashcan code.

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.
Include/object.h
Objects/object.c