Merged revisions 64842,64853,64856,64945 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r64842 | robert.schuppenies | 2008-07-10 15:43:26 +0200 (Thu, 10 Jul 2008) | 2 lines

  Fixed Issue3122 and extended sys.getsizeof tests for built-in types.
........
  r64853 | robert.schuppenies | 2008-07-10 17:24:04 +0200 (Thu, 10 Jul 2008) | 3 lines

  Added additional __sizeof__ implementations and addressed comments made in
  Issue3122.
........
  r64856 | robert.schuppenies | 2008-07-10 19:13:55 +0200 (Thu, 10 Jul 2008) | 3 lines

  Added garbage collector overhead and optional default return value to
  sys.getsizeof.
........
  r64945 | robert.schuppenies | 2008-07-14 10:42:18 +0200 (Mon, 14 Jul 2008) | 2 lines

  Fixed test failure on Win64 machines.
........
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 461fee6..79598f2 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1944,6 +1944,18 @@
 
 PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
 
+static PyObject *
+set_sizeof(PySetObject *so)
+{
+	Py_ssize_t res;
+
+	res = sizeof(PySetObject);
+	if (so->table != so->smalltable)
+		res = res + (so->mask + 1) * sizeof(setentry);
+	return PyLong_FromSsize_t(res);
+}
+
+PyDoc_STRVAR(sizeof_doc, "S.__sizeof__() -> size of S in memory, in bytes");
 static int
 set_init(PySetObject *self, PyObject *args, PyObject *kwds)
 {
@@ -2011,6 +2023,8 @@
 	 reduce_doc},
 	{"remove",	(PyCFunction)set_remove,	METH_O,
 	 remove_doc},
+	{"__sizeof__",	(PyCFunction)set_sizeof,	METH_NOARGS,
+	 sizeof_doc},
 	{"symmetric_difference",(PyCFunction)set_symmetric_difference,	METH_O,
 	 symmetric_difference_doc},
 	{"symmetric_difference_update",(PyCFunction)set_symmetric_difference_update,	METH_O,
@@ -2127,6 +2141,8 @@
 	 issuperset_doc},
 	{"__reduce__",	(PyCFunction)set_reduce,	METH_NOARGS,
 	 reduce_doc},
+	{"__sizeof__",	(PyCFunction)set_sizeof,	METH_NOARGS,
+	 sizeof_doc},
 	{"symmetric_difference",(PyCFunction)set_symmetric_difference,	METH_O,
 	 symmetric_difference_doc},
 	{"union",	(PyCFunction)set_union,		METH_VARARGS,