Wrap at fewer columns.
This commit is contained in:
parent
e7e1852be5
commit
b5146db1e9
36
pep-0442.txt
36
pep-0442.txt
|
@ -54,9 +54,9 @@ Cyclic garbage collector (GC)
|
||||||
Cyclic trash (CT)
|
Cyclic trash (CT)
|
||||||
A reference cycle, or former reference cycle, in which no object
|
A reference cycle, or former reference cycle, in which no object
|
||||||
is referenced from outside the cycle *and* whose objects have
|
is referenced from outside the cycle *and* whose objects have
|
||||||
started being cleared by the GC. Objects in cyclic trash are potential
|
started being cleared by the GC. Objects in cyclic trash are
|
||||||
zombies; if they are accessed by Python code, the symptoms can vary
|
potential zombies; if they are accessed by Python code, the symptoms
|
||||||
from weird AttributeErrors to crashes.
|
can vary from weird AttributeErrors to crashes.
|
||||||
|
|
||||||
Zombie / broken object
|
Zombie / broken object
|
||||||
An object part of cyclic trash. The term stresses that the object
|
An object part of cyclic trash. The term stresses that the object
|
||||||
|
@ -67,13 +67,13 @@ Zombie / broken object
|
||||||
Finalizer
|
Finalizer
|
||||||
A function or method called when an object is intended to be
|
A function or method called when an object is intended to be
|
||||||
disposed of. The finalizer can access the object and release any
|
disposed of. The finalizer can access the object and release any
|
||||||
resource held by the object (for example mutexes or file descriptors).
|
resource held by the object (for example mutexes or file
|
||||||
An example is a ``__del__`` method.
|
descriptors). An example is a ``__del__`` method.
|
||||||
|
|
||||||
Resurrection
|
Resurrection
|
||||||
The process by which a finalizer creates a new reference to an
|
The process by which a finalizer creates a new reference to an
|
||||||
object in a CI. This can happen as a quirky but supported side-effect
|
object in a CI. This can happen as a quirky but supported
|
||||||
of ``__del__`` methods.
|
side-effect of ``__del__`` methods.
|
||||||
|
|
||||||
|
|
||||||
Impact
|
Impact
|
||||||
|
@ -123,23 +123,24 @@ Disposal of cyclic isolates
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
Cyclic isolates are first detected by the garbage collector, and then
|
Cyclic isolates are first detected by the garbage collector, and then
|
||||||
disposed of. The detection phase doesn't change and won't be described here.
|
disposed of. The detection phase doesn't change and won't be described
|
||||||
Disposal of a CI traditionally works in the following order:
|
here. Disposal of a CI traditionally works in the following order:
|
||||||
|
|
||||||
1. Weakrefs to CI objects are cleared, and their callbacks called. At this
|
1. Weakrefs to CI objects are cleared, and their callbacks called. At
|
||||||
point, the objects are still safe to use.
|
this point, the objects are still safe to use.
|
||||||
|
|
||||||
2. The CI becomes a CT as the GC systematically breaks all
|
2. The CI becomes a CT as the GC systematically breaks all
|
||||||
known references inside it (using the ``tp_clear`` function).
|
known references inside it (using the ``tp_clear`` function).
|
||||||
|
|
||||||
3. Nothing. All CT objects should have been disposed of in step 2
|
3. Nothing. All CT objects should have been disposed of in step 2
|
||||||
(as a side-effect of clearing references); this collection is finished.
|
(as a side-effect of clearing references); this collection is
|
||||||
|
finished.
|
||||||
|
|
||||||
This PEP proposes to turn CI disposal into the following sequence (new
|
This PEP proposes to turn CI disposal into the following sequence (new
|
||||||
steps are in bold):
|
steps are in bold):
|
||||||
|
|
||||||
1. Weakrefs to CI objects are cleared, and their callbacks called. At this
|
1. Weakrefs to CI objects are cleared, and their callbacks called. At
|
||||||
point, the objects are still safe to use.
|
this point, the objects are still safe to use.
|
||||||
|
|
||||||
2. **The finalizers of all CI objects are called.**
|
2. **The finalizers of all CI objects are called.**
|
||||||
|
|
||||||
|
@ -152,7 +153,8 @@ steps are in bold):
|
||||||
known references inside it (using the ``tp_clear`` function).
|
known references inside it (using the ``tp_clear`` function).
|
||||||
|
|
||||||
5. Nothing. All CT objects should have been disposed of in step 4
|
5. Nothing. All CT objects should have been disposed of in step 4
|
||||||
(as a side-effect of clearing references); this collection is finished.
|
(as a side-effect of clearing references); this collection is
|
||||||
|
finished.
|
||||||
|
|
||||||
|
|
||||||
C-level changes
|
C-level changes
|
||||||
|
@ -172,8 +174,8 @@ for testing purposes).
|
||||||
|
|
||||||
On the internal side, a bit is reserved in the GC header for GC-managed
|
On the internal side, a bit is reserved in the GC header for GC-managed
|
||||||
objects to signal that they were finalized. This helps avoid finalizing
|
objects to signal that they were finalized. This helps avoid finalizing
|
||||||
an object twice (and, especially, finalizing a CT object after it was broken
|
an object twice (and, especially, finalizing a CT object after it was
|
||||||
by the GC).
|
broken by the GC).
|
||||||
|
|
||||||
|
|
||||||
Discussion
|
Discussion
|
||||||
|
|
Loading…
Reference in New Issue