[Python-checkins] python/dist/src/Objects setobject.c,1.33,1.34

rhettinger@users.sourceforge.net rhettinger at users.sourceforge.net
Sun Jul 31 03:33:12 CEST 2005


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31785

Modified Files:
	setobject.c 
Log Message:
Comment on the set_swap_bodies() helper function.

Index: setobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- setobject.c	31 Jul 2005 01:16:36 -0000	1.33
+++ setobject.c	31 Jul 2005 01:33:10 -0000	1.34
@@ -793,6 +793,19 @@
 	return ((PySetObject *)so)->used;
 }
 
+/* set_swap_bodies() switches the contents of any two sets by moving their
+   internal data pointers and, if needed, copying the internal smalltables.
+   Semantically equivalent to:
+
+     t=set(a); a.clear(); a.update(b); b.clear(); b.update(t); del t
+
+   The function always succeeds and it leaves both objects in a stable state.
+   Useful for creating temporary frozensets from sets for membership testing 
+   in __contains__(), discard(), and remove().  Also useful for operations
+   that update in-place (by allowing an intermediate result to be swapped 
+   into one of original the inputs).
+*/
+
 static void
 set_swap_bodies(PySetObject *a, PySetObject *b)
 {



More information about the Python-checkins mailing list