Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libweakref.tex @ 32160:aec9c98a47d2 legacy-trunk
Add weakref support to sockets and re pattern objects.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Mon, 31 May 2004 03:09:25 +0000 |
| parents | bb7146d117fb |
| children | 541327cb8f8b |
line wrap: on
line diff
--- a/Doc/lib/libweakref.tex Mon May 31 00:35:52 2004 +0000 +++ b/Doc/lib/libweakref.tex Mon May 31 03:09:25 2004 +0000 @@ -48,9 +48,23 @@ Not all objects can be weakly referenced; those objects which can include class instances, functions written in Python (but not in C), -and methods (both bound and unbound). Extension types can easily -be made to support weak references; see section \ref{weakref-extension}, -``Weak References in Extension Types,'' for more information. +methods (both bound and unbound), sets, frozensets, file objects, +sockets, arrays, deques, and regular expression pattern objects. +\versionchanged[Added support for files, sockets, arrays, and patterns]{2.4} + +Several builtin types such as \class{list} and \class{dict} do not +directly support weak references but can add support through subclassing: + +\begin{verbatim} +class Dict(dict): + pass + +obj = Dict(red=1, green=2, blue=3) # this object is weak referencable +\end{verbatim} + +Extension types can easily be made to support weak references; see section +\ref{weakref-extension}, ``Weak References in Extension Types,'' for more +information. \begin{funcdesc}{ref}{object\optional{, callback}}
