Python Dict Packing: Top 3 Reference Counting Costs

Python's dictionary packing incurs reference counting overhead from three primary areas: incrementing for the key object, incrementing for the value object, and the internal operations within functions like `PyDict_SetItem` that manage these counts and hash table insertions. Each of these steps directly modifies the `ob_refcnt` field of `PyObject`s, contributing to performance costs. [9, 10, 11, 15, 16, 22]

Sources

Open the full topic