[Python-checkins] python/dist/src/Objects setobject.c,1.54,1.55

rhettinger@users.sourceforge.net rhettinger at users.sourceforge.net
Wed Aug 24 02:24:51 CEST 2005


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

Modified Files:
	setobject.c 
Log Message:
* Add a fast equality check path for frozensets where the hash value has
  already been computed.
* Apply a GET_SIZE macro().



Index: setobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- setobject.c	17 Aug 2005 12:27:17 -0000	1.54
+++ setobject.c	24 Aug 2005 00:24:40 -0000	1.55
@@ -1495,12 +1495,15 @@
 	case Py_EQ:
 		if (PySet_GET_SIZE(v) != PySet_GET_SIZE(w))
 			Py_RETURN_FALSE;
+		if (v->hash != -1  &&
+		    ((PySetObject *)w)->hash != -1 &&
+		    v->hash != ((PySetObject *)w)->hash)
+			Py_RETURN_FALSE;
 		return set_issubset(v, w);
 	case Py_NE:
-		if (PySet_GET_SIZE(v) != PySet_GET_SIZE(w))
-			Py_RETURN_TRUE;
-		r1 = set_issubset(v, w);
-		assert (r1 != NULL);
+		r1 = set_richcompare(v, w, Py_EQ);
+		if (r1 == NULL)
+			return NULL;
 		r2 = PyBool_FromLong(PyObject_Not(r1));
 		Py_DECREF(r1);
 		return r2;
@@ -1956,7 +1959,7 @@
 		PyErr_BadInternalCall();
 		return -1;
 	}
-	return ((PySetObject *)anyset)->used;
+	return PySet_GET_SIZE(anyset);
 }
 
 int



More information about the Python-checkins mailing list