Dictionaries in CPython allocate a small amount of key space directly in the dictionary object itself (4-8 entries, depending on version and compilation options). From dictobject.h :
#ifndef Py_LIMITED_API #define PyDict_MINSIZE 8
Note that CPython also resizes the dictionary in batches to avoid frequent redistributions for growing dictionaries. From dictobject.c :
if (!(mp->ma_used > n_used && mp->ma_fill*3 >= (mp->ma_mask+1)*2)) return 0; return dictresize(mp, (mp->ma_used > 50000 ? 2 : 4) * mp->ma_used);
nneonneo
source share