Index: python/util.i
===================================================================
--- python/util.i	(revision 15167)
+++ python/util.i	(working copy)
@@ -195,21 +195,22 @@
 /* The GIL must be held when this is called. */
 PyObject *Xapian_MSet_items_get(Xapian::MSet *mset)
 {
-    PyObject *retval = PyList_New(0);
+    PyObject *retval = PyList_New(mset->size());
     if (retval == 0) {
 	return NULL;
     }
 
+    Py_ssize_t idx = 0;
     for (Xapian::MSetIterator i = mset->begin(); i != mset->end(); ++i) {
 	PyObject *t = PyTuple_New(4);
 	if (!t) return NULL;
 
-	PyTuple_SetItem(t, MSET_DID, PyInt_FromLong(*i));
-	PyTuple_SetItem(t, MSET_WT, PyFloat_FromDouble(i.get_weight()));
-	PyTuple_SetItem(t, MSET_RANK, PyInt_FromLong(i.get_rank()));
-	PyTuple_SetItem(t, MSET_PERCENT, PyInt_FromLong(i.get_percent()));
+	PyTuple_SET_ITEM(t, MSET_DID, PyInt_FromLong(*i));
+	PyTuple_SET_ITEM(t, MSET_WT, PyFloat_FromDouble(i.get_weight()));
+	PyTuple_SET_ITEM(t, MSET_RANK, PyInt_FromLong(i.get_rank()));
+	PyTuple_SET_ITEM(t, MSET_PERCENT, PyInt_FromLong(i.get_percent()));
 
-	if (PyList_Append(retval, t) == -1) return NULL;
+	PyList_SET_ITEM(retval, idx++, t);
     }
     return retval;
 }

