[issue28509] Key-sharing dictionaries can inrease the memory consumption

INADA Naoki report at bugs.python.org
Sat Oct 22 22:41:31 EDT 2016


INADA Naoki added the comment:

And I feel current target size of dict_merge is bit larger.

When inserting new item:

* ma_used = dk_size*2 / 3 when right before increasing keys
* ma_used = dk_size    / 3 when right after increasing keys

On the other hand, current dict_merge creates:

* ma_used = dk_size / 2 when all keys in two dict is distinct
* ma_used = dk_size / 4 when all keys in two dict is same

If changing it to dictresize(mp, (mp->ma_used + other->ma_used)*3/2),

* ma_used = dk_size*2 / 3 when all keys in two dict is distinct
* ma_used = dk_size    / 3 when all keys in two dict is same

I think this is more consistent.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28509>
_______________________________________


More information about the Python-bugs-list mailing list