]> granicus.if.org Git - python/commit
SF #1022910: Conserve memory with list.pop()
authorRaymond Hettinger <python@rcn.com>
Sun, 12 Sep 2004 19:53:07 +0000 (19:53 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 12 Sep 2004 19:53:07 +0000 (19:53 +0000)
commita84f3abb9ed70a0b13181698fd8c270dd4abbb88
tree7cbcb9c7c76b73e54751dc52704dd48fe5f67d09
parent0e9980f75a203ee1b2ac28f76a76239446b271d6
SF #1022910: Conserve memory with list.pop()

The list resizing scheme only downsized when more than 16 elements were
removed in a single step:  del a[100:120].   As a result, the list would
never shrink when popping elements off one at a time.

This patch makes it shrink whenever more than half of the space is unused.

Also, at Tim's suggestion, renamed _new_size to new_allocated.  This makes
the code easier to understand.
Objects/listobject.c