Explain Python Dictionary Memory Usage



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.

Updated on: 2020-06-17T11:40:07+05:30

688 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements