summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-06-09 15:19:34 (GMT)
committerGuido van Rossum <guido@python.org>1999-06-09 15:19:34 (GMT)
commitfa71701d46892fe80b1e95279e435533579b3ca7 (patch)
treec36e47cb9a9ba493e76555b6f8a90af5696b8912 /Objects
parent8f3e15058c127c3267183f1e32ddfcdfa1977d11 (diff)
downloadcpython-fa71701d46892fe80b1e95279e435533579b3ca7.zip
cpython-fa71701d46892fe80b1e95279e435533579b3ca7.tar.gz
cpython-fa71701d46892fe80b1e95279e435533579b3ca7.tar.bz2
When deallocating a list, DECREF the items from the end back to the start.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/listobject.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 05da5dc..0342cdc 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -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);