cpython: 8600ae913b63 (original) (raw)
Mercurial > cpython
changeset 78686:8600ae913b63 3.2
Issue #14954: Clarify the interaction of weak references and garbage collection. Patch by Ethan Furman. [#14954]
Antoine Pitrou solipsis@pitrou.net | |
---|---|
date | Tue, 21 Aug 2012 00:07:07 +0200 |
parents | b64947b6f947 |
children | 57c9ed276332 9c22222af1f9 |
files | Doc/library/weakref.rst Misc/ACKS |
diffstat | 2 files changed, 5 insertions(+), 1 deletions(-)[+] [-] Doc/library/weakref.rst 5 Misc/ACKS 1 |
line wrap: on
line diff
--- a/Doc/library/weakref.rst
+++ b/Doc/library/weakref.rst
@@ -24,7 +24,10 @@ by a weak reference.
A weak reference to an object is not enough to keep the object alive: when the
only remaining references to a referent are weak references,
:term:garbage collection
is free to destroy the referent and reuse its memory
-for something else. A primary use for weak references is to implement caches or
+for something else. However, until the object is actually destroyed the weak
+reference may return the object even if there are no strong references to it.
+
+A primary use for weak references is to implement caches or
mappings holding large objects, where it's desired that a large object not be
kept alive solely because it appears in a cache or mapping.
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -317,6 +317,7 @@ Jim Fulton Tadayoshi Funaba Gyro Funch Peter Funk +Ethan Furman Geoff Furnish Ulisses Furquim Hagen Fürstenau