[Python-Dev] When do sets shrink?
Noam Raphael
noamraph at gmail.com
Sat Dec 31 18:15:54 CET 2005
Hello,
I thought about another reason to resize the hash table when it has
too few elements. It's not only a matter of memory usage, it's also a
matter of time usage: iteration over a set or a dict requires going
over all the table. For example, iteration over a set which once had
1,000,000 members and now has 2 can take 1,000,000 operations every
time you traverse all the (2) elements.
Apologies:
1. It may be trivial to you - I'm sorry, I thought about it just now.
2. You can, of course, still do whatever tradeoff you like.
Noam
More information about the Python-Dev
mailing list