From the course: Python Data Structures: Sets and Frozen Sets

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

What is a hash table?

What is a hash table?

- [Instructor] Hash tables are data structures that store key value pairs. In CPython built for 64-bit CPUs, a set contains hash table of at least eight rows. Each row in the table is called a bucket. This is the visual representation of the hash table. Each row in the table is called a bucket. Each bucket is a set of two fields. Each bucket is further divided into two fields. Left hand side, you can see the hash code while right hand side is the hash value. A 64-bit hash code and a 64-bit hash pointer to the element value. Element value is the python object stored elsewhere in the memory. Each bucket has a fixed size and individual buckets are accessed by offset from the start of the table. Zero to seven is the offset or index of the table. Indexes from zero to seven are not stored, they are just off offsets. The hash code for empty buckets is initialized to minus one. Currently, as our table is empty, the hash code is initialized with minus one. Please note if one third of the…

Contents