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

rhettinger@users.sourceforge.net rhettinger at users.sourceforge.net
Sun Jul 31 03:16:38 CEST 2005


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

Modified Files:
	setobject.c 
Log Message:
Revised the set() and frozenset() implementaion to use its own internal
data structure instead of using dictionaries.  Reduces memory consumption
by 1/3 and provides modest speed-ups for most set operations.



Index: setobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/setobject.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- setobject.c	18 Jun 2005 21:00:25 -0000	1.32
+++ setobject.c	31 Jul 2005 01:16:36 -0000	1.33
@@ -1,4 +1,641 @@
+
+/* Set object implementation using a hash table 
+   Functions adapted from dictobject.c
+*/
+
 #include "Python.h"
+
+/* This must be >= 1. */
+#define PERTURB_SHIFT 5
+
+/* Object used as dummy key to fill deleted entries */
[...1390 lines suppressed...]
+		Py_TPFLAGS_BASETYPE,	/* tp_flags */
 	set_doc,			/* tp_doc */
 	(traverseproc)set_traverse,	/* tp_traverse */
 	(inquiry)set_tp_clear,		/* tp_clear */
 	(richcmpfunc)set_richcompare,	/* tp_richcompare */
 	offsetof(PySetObject, weakreflist),	/* tp_weaklistoffset */
-	(getiterfunc)set_iter,		/* tp_iter */
+	(getiterfunc)set_iter,	/* tp_iter */
 	0,				/* tp_iternext */
 	set_methods,			/* tp_methods */
 	0,				/* tp_members */
@@ -1120,7 +1772,7 @@
 	0,				/* tp_setattro */
 	0,				/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES |
-		Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS,	/* tp_flags */
+		Py_TPFLAGS_BASETYPE,	/* tp_flags */
 	frozenset_doc,			/* tp_doc */
 	(traverseproc)set_traverse,	/* tp_traverse */
 	0,				/* tp_clear */



More information about the Python-checkins mailing list