]> granicus.if.org Git - python/commitdiff
When deallocating a list, DECREF the items from the end back to the start.
authorGuido van Rossum <guido@python.org>
Wed, 9 Jun 1999 15:19:34 +0000 (15:19 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 9 Jun 1999 15:19:34 +0000 (15:19 +0000)
Objects/listobject.c

index 05da5dcc0fe6895a273397781ce2f2a5c1d0735b..0342cdcb38630582be561102313b5120104d5864 100644 (file)
@@ -216,7 +216,12 @@ list_dealloc(op)
 {
        int i;
        if (op->ob_item != NULL) {
-               for (i = 0; i < op->ob_size; i++) {
+               /* Do it backwards, for Christian Tismer.
+                  There's a simple test case where somehow this reduces
+                  thrashing when a *very* large list is created and
+                  immediately deleted. */
+               i = op->ob_size;
+               while (--i >= 0) {
                        Py_XDECREF(op->ob_item[i]);
                }
                free((ANY *)op->ob_item);