@@ -22,11 +22,50 @@ typedef Py_ssize_t (*dict_lookup_func)
2222/* See dictobject.c for actual layout of DictKeysObject */
2323struct _dictkeysobject {
2424 Py_ssize_t dk_refcnt ;
25+
26+ /* Size of the hash table (dk_indices). It must be a power of 2. */
2527 Py_ssize_t dk_size ;
28+
29+ /* Function to lookup in the hash table (dk_indices):
30+
31+ - lookdict(): general-purpose, and may return DKIX_ERROR if (and
32+ only if) a comparison raises an exception.
33+
34+ - lookdict_unicode(): specialized to Unicode string keys, comparison of
35+ which can never raise an exception; that function can never return
36+ DKIX_ERROR.
37+
38+ - lookdict_unicode_nodummy(): similar to lookdict_unicode() but further
39+ specialized for Unicode string keys that cannot be the <dummy> value.
40+
41+ - lookdict_split(): Version of lookdict() for split tables. */
2642 dict_lookup_func dk_lookup ;
43+
44+ /* Number of usable entries in dk_entries.
45+ 0 <= dk_usable <= USABLE_FRACTION(dk_size) */
2746 Py_ssize_t dk_usable ;
28- Py_ssize_t dk_nentries ; /* How many entries are used. */
29- char dk_indices [8 ]; /* dynamically sized. 8 is minimum. */
47+
48+ /* Number of used entries in dk_entries.
49+ 0 <= dk_nentries < dk_size */
50+ Py_ssize_t dk_nentries ;
51+
52+ /* Actual hash table of dk_size entries. It holds indices in dk_entries,
53+ or DKIX_EMPTY(-1) or DKIX_DUMMY(-2).
54+
55+ Indices must be: 0 <= indice < USABLE_FRACTION(dk_size).
56+
57+ The size in bytes of an indice depends on dk_size:
58+
59+ - 1 byte if dk_size <= 0xff (char*)
60+ - 2 bytes if dk_size <= 0xffff (int16_t*)
61+ - 4 bytes if dk_size <= 0xffffffff (int32_t*)
62+ - 8 bytes otherwise (Py_ssize_t*)
63+
64+ Dynamically sized, 8 is minimum. */
65+ char dk_indices [8 ];
66+
67+ /* "PyDictKeyEntry dk_entries[dk_usable];" array follows:
68+ see the DK_ENTRIES() macro */
3069};
3170
3271#endif
0 commit comments