[Python-Dev] pep 422 "Safe object finalization" question: why break weakrefs first?
Russell E. Owen
rowen at uw.edu
Tue May 28 21:21:25 CEST 2013
Pep 422 proposes the following order for dealing with cyclic isolates:
1. Weakrefs to CI objects are cleared, and their callbacks called. At
this point, the objects are still safe to use.
2. The finalizers of all CI objects are called.
3. The CI is traversed again to determine if it is still isolated. If
it is determined that at least one object in CI is now reachable from
outside the CI, this collection is aborted and the whole CI is
resurrected. Otherwise, proceed.
4. The CI becomes a CT as the GC systematically breaks all known
references inside it (using the tp_clear function).
Why are weakrefs are broken first, before determining if any of the
objects should become resurrected? Naively I would expect weakrefs to be
broken after step 3, once the system is sure no objects have been
I request that this information be added to PEP 422.
More information about the Python-Dev