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

source code of include/python3.10/cpython/dictobject.h