Can you please explain Python dictionary memory usage?

PythonProgramming

The dictionary consists of a number of buckets. Each of these buckets contains

  • the hash code of the object currently stored (that is not predictable from the position of the bucket due to the collision resolution strategy used)
  • a pointer to the key object
  • a pointer to the value object

This sums up to at least 12 bytes on a 32bit machine and 24 bytes on a 64bit machine. The dictionary starts with 8 empty buckets. This is then resized by doubling the number of entries whenever its capacity is reached.

raja
Published on 18-Apr-2018 13:36:59
Advertisements