[Python-Dev] py2.7: dictobject not properly resizing (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Sat Mar 30 22:37:01 CET 2013


On Sat, 30 Mar 2013 17:31:26 -0400 Micha Gorelick <mynameisfiber at gmail.com> wrote:

I was taking a look at dictobject.c and realized that the logic controlling whether a resizedict will occur in dictsetitembyhashorentry disallows for the shrinking of a dictionary. This is contrary to what the comments directly above say:

Also in 3.4:

d = {i: i for i in range(1000)} sys.getsizeof(d) 49264 for i in range(900): del d[i] ... sys.getsizeof(d) 49264 for i in range(900, 1000): del d[i] ... sys.getsizeof(d) 49264 len(d) 0 d.clear() sys.getsizeof(d) 88

Regards

Antoine.



More information about the Python-Dev mailing list