Skip to content

Commit a2ed8a2

Browse files
committed
Add an explaining comment for _Py_HAMT_MAX_TREE_DEPTH
1 parent 2aa4cd6 commit a2ed8a2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

immutables/_map.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
#include <stdint.h>
55
#include "Python.h"
66

7+
/*
8+
HAMT tree is shaped by hashes of keys. Every group of 5 bits of a hash denotes
9+
the exact position of the key in one level of the tree. Since we're using
10+
32 bit hashes, we can have at most 7 such levels. Although if there are
11+
two distinct keys with equal hashes, they will have to occupy the same
12+
cell in the 7th level of the tree -- so we'd put them in a "collision" node.
13+
Which brings the total possible tree depth to 8. Read more about the actual
14+
layout of the HAMT tree in `_map.c`.
15+
16+
This constant is used to define a datastucture for storing iteration state.
17+
*/
718
#define _Py_HAMT_MAX_TREE_DEPTH 8
819

920

0 commit comments

Comments
 (0)