@@ -219,17 +219,17 @@ they started originally) and setting its ``gc_refs`` field to 1. This is what ha
219219to ``link_2 `` and ``link_3 `` below as they are reachable from ``link_1 ``. From the
220220state in the previous image and after examining the objects referred to by ``link_1 ``
221221the GC knows that ``link_3 `` is reachable after all, so it is moved back to the
222- original list and its ``gc_refs `` field is set to one so if the GC visits it again, it
223- does know that is reachable. To avoid visiting a object twice, the GC marks all
224- objects that are already visited once (by unsetting the ``PREV_MASK_COLLECTING `` flag)
225- so if an object that has already been processed is referred by some other object, the
226- GC does not process it twice.
222+ original list and its ``gc_refs `` field is set to 1 so that if the GC visits it again,
223+ it will know that it's reachable. To avoid visiting an object twice, the GC marks all
224+ objects that have already been visited once (by unsetting the ``PREV_MASK_COLLECTING ``
225+ flag) so that if an object that has already been processed is referenced by some other
226+ object, the GC does not process it twice.
227227
228228.. figure :: images/python-cyclic-gc-5-new-page.png
229229
230- Notice that once an object that was marked as "tentatively unreachable" and later is
231- moved back to the reachable list, it will be visited again by the garbage collector
232- as now all the references that that objects has need to be processed as well. This
230+ Notice that an object that was marked as "tentatively unreachable" and was later
231+ moved back to the reachable list will be visited again by the garbage collector
232+ as now all the references that that object has need to be processed as well. This
233233process is really a breadth first search over the object graph. Once all the objects
234234are scanned, the GC knows that all container objects in the tentatively unreachable
235235list are really unreachable and can thus be garbage collected.
@@ -276,7 +276,7 @@ follows these steps in order:
276276 set is going to be destroyed and has weak references with callbacks, these
277277 callbacks need to be honored. This process is **very ** delicate as any error can
278278 cause objects that will be in an inconsistent state to be resurrected or reached
279- by some python functions invoked from the callbacks. In addition, weak references
279+ by some Python functions invoked from the callbacks. In addition, weak references
280280 that also are part of the unreachable set (the object and its weak reference
281281 are in cycles that are unreachable) need to be cleaned
282282 immediately, without executing the callback. Otherwise it will be triggered later,
@@ -304,9 +304,9 @@ optimization: generations. The main idea behind this concept is the assumption t
304304most objects have a very short lifespan and can thus be collected shortly after their
305305creation. This has proven to be very close to the reality of many Python programs as
306306many temporarily objects are created and destroyed very fast. The older an object is
307- the less likely it is to become unreachable.
307+ the less likely it is that it will become unreachable.
308308
309- To take advantage of this fact, all container objects are segregated across
309+ To take advantage of this fact, all container objects are segregated into
310310three spaces/generations. Every new
311311object starts in the first generation (generation 0). The previous algorithm is
312312executed only over the objects of a particular generation and if an object
@@ -316,7 +316,7 @@ the same object survives another GC round in this new generation (generation 1)
316316it will be moved to the last generation (generation 2) where it will be
317317surveyed the least often.
318318
319- Generations are collected when the number of objects that they contain reach some
319+ Generations are collected when the number of objects that they contain reaches some
320320predefined threshold, which is unique for each generation and is lower the older
321321the generations are. These thresholds can be examined using the ``gc.get_threshold ``
322322function:
@@ -402,10 +402,10 @@ bit a separate tag) – as long as code that uses the pointer masks out these
402402bits before accessing memory. E.g., on a 32-bit architecture (for both
403403addresses and word size), a word is 32 bits = 4 bytes, so word-aligned
404404addresses are always a multiple of 4, hence end in ``00 ``, leaving the last 2 bits
405- available; while on a 64-bit architecture, a word is 64 bits word = 8 bytes, so
405+ available; while on a 64-bit architecture, a word is 64 bits = 8 bytes, so
406406word-aligned addresses end in ``000 ``, leaving the last 3 bits available.
407407
408- The CPython GC makes use of two fat pointers that corresponds to the extra fields
408+ The CPython GC makes use of two fat pointers that correspond to the extra fields
409409of ``PyGC_Head `` discussed in the `Memory layout and object structure `_ section:
410410
411411 .. warning ::
@@ -440,7 +440,7 @@ Optimization: delay tracking containers
440440
441441Certain types of containers cannot participate in a reference cycle, and so do
442442not need to be tracked by the garbage collector. Untracking these objects
443- reduces the cost of garbage collections . However, determining which objects may
443+ reduces the cost of garbage collection . However, determining which objects may
444444be untracked is not free, and the costs must be weighed against the benefits
445445for garbage collection. There are two possible strategies for when to untrack
446446a container:
@@ -470,7 +470,7 @@ benefit from delayed tracking:
470470 full garbage collection (all generations), the collector will untrack any dictionaries
471471 whose contents are not tracked.
472472
473- The garbage collector module provides the python function is_tracked(obj), which returns
473+ The garbage collector module provides the Python function `` is_tracked(obj) `` , which returns
474474the current tracking status of the object. Subsequent garbage collections may change the
475475tracking status of the object.
476476
0 commit comments