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