Skip to content

Commit 17077dc

Browse files
authored
Make minor editorial corrections in the garbage collector section (#608)
1 parent f7f816e commit 17077dc

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

garbage_collector.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ As is explained later in the `Optimization: reusing fields to save memory`_ sect
9292
these two extra fields are normally used to keep doubly linked lists of all the
9393
objects tracked by the garbage collector (these lists are the GC generations, more on
9494
that in the `Optimization: generations`_ section), but they are also
95-
reused to fullfill other purposes when the full doubly linked list structure is not
95+
reused to fulfill other purposes when the full doubly linked list structure is not
9696
needed as a memory optimization.
9797

9898
Doubly linked lists are used because they efficiently support most frequently required operations. In
@@ -117,7 +117,7 @@ that the objects cannot form reference cycles with only objects of its type or u
117117
the type is immutable, a ``tp_clear`` implementation must also be provided.
118118

119119

120-
Identifiying reference cycles
120+
Identifying reference cycles
121121
----------------------------------------------
122122

123123
The algorithm that CPython uses to detect those reference cycles is
@@ -164,7 +164,9 @@ is completely unreachable:
164164
165165
>>> link_4 = Link()
166166
>>> link_4.next_link = link_4
167+
>>> del link_4
167168
169+
# Collect the unreachable Link object (and its .__dict__ dict).
168170
>>> gc.collect()
169171
2
170172
@@ -285,7 +287,7 @@ follows these steps in order:
285287
2. If an object has legacy finalizers (``tp_del`` slot) move them to the
286288
``gc.garbage`` list.
287289
3. Call the finalizers (``tp_finalize`` slot) and mark the objects as already
288-
finalized to avoid calling them twice if they resurrect of if other finalizers
290+
finalized to avoid calling them twice if they resurrect or if other finalizers
289291
have removed the object first.
290292
4. Deal with resurrected objects. If some objects have been resurrected, the GC
291293
finds the new subset of objects that are still unreachable by running the cycle
@@ -337,23 +339,23 @@ specifically in a generation by calling ``gc.collect(generation=NUM)``.
337339
... pass
338340
...
339341
340-
# Move everything to the last generation so its easier to inspect
342+
# Move everything to the last generation so it's easier to inspect
341343
# the younger generations.
342344
343345
>>> gc.collect()
344346
0
345347
346-
# Create a reference cycle
348+
# Create a reference cycle.
347349
348350
>>> x = MyObj()
349351
>>> x.self = x
350352
351-
# Initially the object is in the younguest generation.
353+
# Initially the object is in the youngest generation.
352354
353355
>>> gc.get_objects(generation=0)
354356
[..., <__main__.MyObj object at 0x7fbcc12a3400>, ...]
355357
356-
# After a collection of the younguest generation the object
358+
# After a collection of the youngest generation the object
357359
# moves to the next generation.
358360
359361
>>> gc.collect(generation=0)

0 commit comments

Comments
 (0)