• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7 /* The ma_values pointer is NULL for a combined table
8  * or points to an array of PyObject* for a split table
9  */
10 typedef 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 
30 PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
31                                        Py_hash_t hash);
32 PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
33                                                   struct _Py_Identifier *key);
34 PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
35 PyAPI_FUNC(PyObject *) PyDict_SetDefault(
36     PyObject *mp, PyObject *key, PyObject *defaultobj);
37 PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
38                                           PyObject *item, Py_hash_t hash);
39 PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
40                                           Py_hash_t hash);
41 PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
42                                   int (*predicate)(PyObject *value));
43 PyDictKeysObject *_PyDict_NewKeysForClass(void);
44 PyAPI_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)
49 PyAPI_FUNC(int) _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
50 PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, struct _Py_Identifier *);
51 PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
52 PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
53 PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
54 Py_ssize_t _PyDict_KeysSize(PyDictKeysObject *keys);
55 PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *);
56 PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *, PyObject *, PyObject *);
57 PyObject *_PyDict_Pop_KnownHash(PyObject *, PyObject *, Py_hash_t, PyObject *);
58 PyObject *_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 */
66 PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
67 PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
68 
69 PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
70 PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
71 
72 int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
73 PyObject *_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *);
74 Py_ssize_t _PyDict_GetItemHint(PyDictObject *, PyObject *, Py_ssize_t, PyObject **);
75 
76 /* _PyDictView */
77 
78 typedef struct {
79     PyObject_HEAD
80     PyDictObject *dv_dict;
81 } _PyDictViewObject;
82 
83 PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
84 PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
85