[Python-checkins] python/dist/src/Doc/lib libsets.tex, 1.15.4.1, 1.15.4.2 libstdtypes.tex, 1.170.2.5, 1.170.2.6

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sun Apr 10 19:36:28 CEST 2005


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21540

Modified Files:
      Tag: release24-maint
	libsets.tex libstdtypes.tex 
Log Message:
SF bug #1179957:  Missing def'n of equality for set element



Index: libsets.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsets.tex,v
retrieving revision 1.15.4.1
retrieving revision 1.15.4.2
diff -u -d -r1.15.4.1 -r1.15.4.2
--- libsets.tex	19 Jan 2005 07:23:35 -0000	1.15.4.1
+++ libsets.tex	10 Apr 2005 17:36:26 -0000	1.15.4.2
@@ -30,7 +30,10 @@
 abstract class useful for determining whether something is a set:
 \code{isinstance(\var{obj}, BaseSet)}.
 
-The set classes are implemented using dictionaries.  As a result, sets
+The set classes are implemented using dictionaries.  Accordingly, the
+requirements for set elements are the same as those for dictionary keys;
+namely, that the element defines both \method{__eq__} and \method{__hash__}.
+As a result, sets
 cannot contain mutable elements such as lists or dictionaries.
 However, they can contain immutable collections such as tuples or
 instances of \class{ImmutableSet}.  For convenience in implementing

Index: libstdtypes.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v
retrieving revision 1.170.2.5
retrieving revision 1.170.2.6
diff -u -d -r1.170.2.5 -r1.170.2.6
--- libstdtypes.tex	9 Feb 2005 23:23:10 -0000	1.170.2.5
+++ libstdtypes.tex	10 Apr 2005 17:36:26 -0000	1.170.2.6
@@ -1220,6 +1220,9 @@
 Since sets only define partial ordering (subset relationships), the output
 of the \method{list.sort()} method is undefined for lists of sets.
 
+Set elements are like dictionary keys; they need to define both
+\method{__hash__} and \method{__eq__} methods.
+
 Binary operations that mix \class{set} instances with \class{frozenset}
 return the type of the first operand.  For example:
 \samp{frozenset('ab') | set('bc')} returns an instance of \class{frozenset}.



More information about the Python-checkins mailing list