1 #ifndef Py_CPYTHON_DICTOBJECT_H
2 #  error "this header file must not be included directly"
3 #endif
4 
5 typedef struct _dictkeysobject PyDictKeysObject;
6 typedef struct _dictvalues PyDictValues;
7 
8 /* The ma_values pointer is NULL for a combined table
9  * or points to an array of PyObject* for a split table
10  */
11 typedef struct {
12     PyObject_HEAD
13 
14     /* Number of items in the dictionary */
15     Py_ssize_t ma_used;
16 
17     /* Dictionary version: globally unique, value change each time
18        the dictionary is modified */
19     uint64_t ma_version_tag;
20 
21     PyDictKeysObject *ma_keys;
22 
23     /* If ma_values is NULL, the table is "combined": keys and values
24        are stored in ma_keys.
25 
26        If ma_values is not NULL, the table is split:
27        keys are stored in ma_keys and values are stored in ma_values */
28     PyDictValues *ma_values;
29 } PyDictObject;
30 
31 PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
32                                        Py_hash_t hash);
33 PyAPI_FUNC(PyObject *) _PyDict_GetItemWithError(PyObject *dp, PyObject *key);
34 PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
35                                                   _Py_Identifier *key);
36 PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
37 PyAPI_FUNC(PyObject *) PyDict_SetDefault(
38     PyObject *mp, PyObject *key, PyObject *defaultobj);
39 PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
40                                           PyObject *item, Py_hash_t hash);
41 PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
42                                           Py_hash_t hash);
43 PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
44                                   int (*predicate)(PyObject *value));
45 PyAPI_FUNC(int) _PyDict_Next(
46     PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
47 
48 /* Get the number of items of a dictionary. */
49 #define PyDict_GET_SIZE(mp)  (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used)
50 PyAPI_FUNC(int) _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
51 PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, _Py_Identifier *);
52 PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
53 PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
54 PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
55 PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *);
56 PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *, PyObject *, PyObject *);
57 #define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL)
58 
59 /* Like PyDict_Merge, but override can be 0, 1 or 2.  If override is 0,
60    the first occurrence of a key wins, if override is 1, the last occurrence
61    of a key wins, if override is 2, a KeyError with conflicting key as
62    argument is raised.
63 */
64 PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
65 PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject *item);
66 
67 PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key);
68 PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
69 
70 /* _PyDictView */
71 
72 typedef struct {
73     PyObject_HEAD
74     PyDictObject *dv_dict;
75 } _PyDictViewObject;
76 
77 PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
78 PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
79