Apparently deleting entries in the dictionary does not cause any changes. Resizing starts only after adding a record.
This can be seen from the following:
as well as a question about SO (from what I found). set behave similarly to what you would expect according to what dicts do.
list s, on the other hand, resize when the new size becomes half the size already selected; this is indicated in the list_resize comment :
Why dictionaries (and, indirectly, sets) do not use such a trick and instead wait for a new entry to be entered? The behavior described applies to Python 2.7 and 3.x (up to Python 3.7.0a0).
python dictionary python-internals
Jim fasarakis hilliard
source share