Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 151ea69..5405fec 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3397,6 +3397,20 @@
         return result;
 }
 
+static PyObject *
+object_sizeof(PyObject *self, PyObject *args)
+{
+	Py_ssize_t res, isize;
+
+	res = 0;
+	isize = self->ob_type->tp_itemsize;
+	if (isize > 0)
+		res = self->ob_type->ob_size * isize;
+	res += self->ob_type->tp_basicsize;
+
+	return PyInt_FromSsize_t(res);	 
+}
+
 static PyMethodDef object_methods[] = {
 	{"__reduce_ex__", object_reduce_ex, METH_VARARGS,
 	 PyDoc_STR("helper for pickle")},
@@ -3406,6 +3420,8 @@
 	 object_subclasshook_doc},
         {"__format__", object_format, METH_VARARGS,
          PyDoc_STR("default object formatter")},
+        {"__sizeof__", object_sizeof, METH_NOARGS,
+         PyDoc_STR("__sizeof__() -> size of object in bytes")},
 	{0}
 };