@@ -191,38 +191,38 @@ The GC then iterates over all containers in the first list and decrements by one
191
191
this makes use of the ``tp_traverse `` slot in the container class (implemented
192
192
using the C API or inherited by a superclass) to know what objects are referenced by
193
193
each container. After all the objects have been scanned, only the objects that have
194
- references from outside the “objects to scan” list will have ``gc_refs > 0 ``.
194
+ references from outside the “objects to scan” list will have ``gc_ref > 0 ``.
195
195
196
196
.. figure :: /_static/python-cyclic-gc-2-new-page.png
197
197
198
- Notice that having ``gc_refs == 0 `` does not imply that the object is unreachable.
199
- This is because another object that is reachable from the outside (``gc_refs > 0 ``)
198
+ Notice that having ``gc_ref == 0 `` does not imply that the object is unreachable.
199
+ This is because another object that is reachable from the outside (``gc_ref > 0 ``)
200
200
can still have references to it. For instance, the ``link_2 `` object in our example
201
- ended having ``gc_refs == 0 `` but is referenced still by the ``link_1 `` object that
201
+ ended having ``gc_ref == 0 `` but is referenced still by the ``link_1 `` object that
202
202
is reachable from the outside. To obtain the set of objects that are really
203
203
unreachable, the garbage collector re-scans the container objects using the
204
204
``tp_traverse `` slot; this time with a different traverse function that marks objects with
205
- ``gc_refs == 0 `` as "tentatively unreachable" and then moves them to the
205
+ ``gc_ref == 0 `` as "tentatively unreachable" and then moves them to the
206
206
tentatively unreachable list. The following image depicts the state of the lists in a
207
207
moment when the GC processed the ``link_3 `` and ``link_4 `` objects but has not
208
208
processed ``link_1 `` and ``link_2 `` yet.
209
209
210
210
.. figure :: /_static/python-cyclic-gc-3-new-page.png
211
211
212
- Then the GC scans the next ``link_1 `` object. Because it has ``gc_refs == 1 ``,
212
+ Then the GC scans the next ``link_1 `` object. Because it has ``gc_ref == 1 ``,
213
213
the gc does not do anything special because it knows it has to be reachable (and is
214
214
already in what will become the reachable list):
215
215
216
216
.. figure :: /_static/python-cyclic-gc-4-new-page.png
217
217
218
- When the GC encounters an object which is reachable (``gc_refs > 0 ``), it traverses
218
+ When the GC encounters an object which is reachable (``gc_ref > 0 ``), it traverses
219
219
its references using the ``tp_traverse `` slot to find all the objects that are
220
220
reachable from it, moving them to the end of the list of reachable objects (where
221
- they started originally) and setting its ``gc_refs `` field to 1. This is what happens
221
+ they started originally) and setting its ``gc_ref `` field to 1. This is what happens
222
222
to ``link_2 `` and ``link_3 `` below as they are reachable from ``link_1 ``. From the
223
223
state in the previous image and after examining the objects referred to by ``link_1 ``
224
224
the GC knows that ``link_3 `` is reachable after all, so it is moved back to the
225
- original list and its ``gc_refs `` field is set to 1 so that if the GC visits it again,
225
+ original list and its ``gc_ref `` field is set to 1 so that if the GC visits it again,
226
226
it will know that it's reachable. To avoid visiting an object twice, the GC marks all
227
227
objects that have already been visited once (by unsetting the ``PREV_MASK_COLLECTING ``
228
228
flag) so that if an object that has already been processed is referenced by some other
@@ -431,7 +431,7 @@ of ``PyGC_Head`` discussed in the `Memory layout and object structure`_ section:
431
431
``PREV_MASK_COLLECTING `` and ``_PyGC_PREV_MASK_FINALIZED ``. Between collections,
432
432
the only flag that can be present is ``_PyGC_PREV_MASK_FINALIZED `` that indicates
433
433
if an object has been already finalized. During collections ``_gc_prev `` is
434
- temporarily used for storing a copy of the reference count (``gc_refs ``), in
434
+ temporarily used for storing a copy of the reference count (``gc_ref ``), in
435
435
addition to two flags, and the GC linked list becomes a singly linked list until
436
436
``_gc_prev `` is restored.
437
437
0 commit comments