[Python-Dev] Idea: more compact, interned string key only dict for namespace.
songofacandy at gmail.com
Thu Jun 23 00:08:27 EDT 2016
> Memory usage
> on amd64 arch.
> key-sharing dict:
> * 96 bytes for ~3 items
> * 128 bytes for 4~5 items.
Note: There are another shared key.
* 128 bytes for ~3 items
* 224 bytes for 4~5 items
So, let S = how many instances shares the key,
* 90 + (96 / S) bytes for ~3 items
* 128 + (224 / S) bytes for 4~5 items
> compact dict:
> * 224 bytes for ~5 items.
> (232 bytes when keep supporting key-shared dict)
> interned key only dict:
> * 184 bytes for ~5 items
> Interned key only dict is still larger than key-shared dict.
> But it can be used for more purpose. It can be used for interning string
> for example. It can be used to kwargs dict when all keys are interned already.
> If we provide _PyDict_NewForNamespace to extension modules,
> json decoder can have option to use this, too.
> INADA Naoki <songofacandy at gmail.com>
INADA Naoki <songofacandy at gmail.com>
More information about the Python-Dev