mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
When deallocating a list, DECREF the items from the end back to the start.
This commit is contained in:
parent
8f3e15058c
commit
fa71701d46
1 changed files with 6 additions and 1 deletions
|
|
@ -216,7 +216,12 @@ list_dealloc(op)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (op->ob_item != NULL) {
|
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]);
|
Py_XDECREF(op->ob_item[i]);
|
||||||
}
|
}
|
||||||
free((ANY *)op->ob_item);
|
free((ANY *)op->ob_item);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue