[Python-Dev] When do sets shrink?

Noam Raphael noamraph at gmail.com
Thu Dec 29 00:22:03 CET 2005


Hello,

If I do something like this:

s = set()
for i in xrange(1000000):
    s.add(i)
while s:
    s.pop()
gc.collect()

the memory consumption of the process remains the same even after the pops.

I checked the code (that's where I started from, really), and there's
nothing in set.pop or set.remove that resizes the table. And it turns
out that it's the same with dicts.

Should something be done about it?

Noam


More information about the Python-Dev mailing list