Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.

(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode.  I'm also holding back on his
change to main.c, which seems unnecessary to me.)
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index d1627a9..d5d6a07 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -80,10 +80,12 @@
 #ifdef COUNT_ALLOCS
 		fast_tuple_allocs++;
 #endif
+		/* PyObject_InitVar is inlined */
 #ifdef Py_TRACE_REFS
-		op->ob_type = &PyTuple_Type;
 		op->ob_size = size;
+		op->ob_type = &PyTuple_Type;
 #endif
+		_Py_NewReference((PyObject *)op);
 	}
 	else
 #endif
@@ -96,17 +98,15 @@
 		{
 			return PyErr_NoMemory();
 		}
-		;
-		op = (PyTupleObject *) malloc(nbytes);
+		/* PyObject_NewVar is inlined */
+		op = (PyTupleObject *) PyObject_MALLOC(nbytes);
 		if (op == NULL)
 			return PyErr_NoMemory();
 
-		op->ob_type = &PyTuple_Type;
-		op->ob_size = size;
+		PyObject_INIT_VAR(op, &PyTuple_Type, size);
 	}
 	for (i = 0; i < size; i++)
 		op->ob_item[i] = NULL;
-	_Py_NewReference((PyObject *)op);
 #if MAXSAVESIZE > 0
 	if (size == 0) {
 		free_tuples[0] = op;
@@ -193,7 +193,7 @@
 		}
 #endif
 	}
-	free((ANY *)op);
+	PyObject_DEL(op);
 done:
 	Py_TRASHCAN_SAFE_END(op)
 }
@@ -530,11 +530,11 @@
 #endif		
 	{
 		sv = (PyTupleObject *)
-			realloc((char *)v,
+			PyObject_REALLOC((char *)v,
 				sizeof(PyTupleObject) + newsize * sizeof(PyObject *));
 		*pv = (PyObject *) sv;
 		if (sv == NULL) {
-			PyMem_DEL(v);
+			PyObject_DEL(v);
 			PyErr_NoMemory();
 			return -1;
 		}
@@ -569,7 +569,7 @@
 		while (p) {
 			q = p;
 			p = (PyTupleObject *)(p->ob_item[0]);
-			PyMem_DEL(q);
+			PyObject_DEL(q);
 		}
 	}
 #endif