[Python-checkins] r53830 - python/branches/release25-maint/Objects/setobject.c

raymond.hettinger python-checkins at python.org
Mon Feb 19 21:45:47 CET 2007


Author: raymond.hettinger
Date: Mon Feb 19 21:45:46 2007
New Revision: 53830

Modified:
   python/branches/release25-maint/Objects/setobject.c
Log:
Fixup set/dict interoperability.

Modified: python/branches/release25-maint/Objects/setobject.c
==============================================================================
--- python/branches/release25-maint/Objects/setobject.c	(original)
+++ python/branches/release25-maint/Objects/setobject.c	Mon Feb 19 21:45:46 2007
@@ -919,7 +919,18 @@
 		PyObject *value;
 		Py_ssize_t pos = 0;
 		long hash;
+		Py_ssize_t dictsize = PyDict_Size(other);
 
+		/* Do one big resize at the start, rather than
+		* incrementally resizing as we insert new keys.  Expect
+		* that there will be no (or few) overlapping keys.
+		*/
+		if (dictsize == -1)
+			return -1;
+		if ((so->fill + dictsize)*3 >= (so->mask+1)*2) {
+			if (set_table_resize(so, (so->used + dictsize)*2) != 0)
+				return -1;
+		}
 		while (_PyDict_Next(other, &pos, &key, &value, &hash)) {
 			setentry an_entry;
 


More information about the Python-checkins mailing list