Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libsets.tex @ 27887:cedf9efa68f8 legacy-trunk
SF bug #663701: sets module review
Renamed hook methods to use the double underscore convention.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 14 Feb 2003 03:42:11 +0000 |
| parents | 206c5e3b5be7 |
| children | 60aae8a1e237 a332dcc7902b |
line wrap: on
line diff
--- a/Doc/lib/libsets.tex Fri Feb 14 01:49:09 2003 +0000 +++ b/Doc/lib/libsets.tex Fri Feb 14 03:42:11 2003 +0000 @@ -203,23 +203,23 @@ The mechanism is to always add a hashable element, or if it is not hashable, the element is checked to see if it has an -\method{_as_immutable()} method which returns an immutable equivalent. +\method{__as_immutable__()} method which returns an immutable equivalent. -Since \class{Set} objects have a \method{_as_immutable()} method +Since \class{Set} objects have a \method{__as_immutable__()} method returning an instance of \class{ImmutableSet}, it is possible to construct sets of sets. A similar mechanism is needed by the \method{__contains__()} and \method{remove()} methods which need to hash an element to check for membership in a set. Those methods check an element for hashability -and, if not, check for a \method{_as_temporarily_immutable()} method +and, if not, check for a \method{__as_temporarily_immutable__()} method which returns the element wrapped by a class that provides temporary methods for \method{__hash__()}, \method{__eq__()}, and \method{__ne__()}. The alternate mechanism spares the need to build a separate copy of the original mutable object. -\class{Set} objects implement the \method{_as_temporarily_immutable()} +\class{Set} objects implement the \method{__as_temporarily_immutable__()} method which returns the \class{Set} object wrapped by a new class \class{_TemporarilyImmutableSet}.
