1#ifndef Py_DICTOBJECT_H
2#define Py_DICTOBJECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7/* Dictionary object type -- mapping from hashable object to object */
8
9/* The distribution includes a separate file, Objects/dictnotes.txt,
10 describing explorations into dictionary design and optimization.
11 It covers typical dictionary use patterns, the parameters for
12 tuning dictionaries, and several ideas for possible optimizations.
13*/
14
15PyAPI_DATA(PyTypeObject) PyDict_Type;
16
17#define PyDict_Check(op) \
18 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
19#define PyDict_CheckExact(op) Py_IS_TYPE(op, &PyDict_Type)
20
21PyAPI_FUNC(PyObject *) PyDict_New(void);
22PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
23PyAPI_FUNC(PyObject *) PyDict_GetItemWithError(PyObject *mp, PyObject *key);
24PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
25PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
26PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
27PyAPI_FUNC(int) PyDict_Next(
28 PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
29PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
30PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
31PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
32PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
33PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
34PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
35
36/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
37PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
38
39/* PyDict_Merge updates/merges from a mapping object (an object that
40 supports PyMapping_Keys() and PyObject_GetItem()). If override is true,
41 the last occurrence of a key wins, else the first. The Python
42 dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).
43*/
44PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
45 PyObject *other,
46 int override);
47
48/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing
49 iterable objects of length 2. If override is true, the last occurrence
50 of a key wins, else the first. The Python dict constructor dict(seq2)
51 is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).
52*/
53PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
54 PyObject *seq2,
55 int override);
56
57PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
58PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
59PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
60#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
61PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *);
62#endif
63
64/* Dictionary (keys, values, items) views */
65
66PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
67PyAPI_DATA(PyTypeObject) PyDictValues_Type;
68PyAPI_DATA(PyTypeObject) PyDictItems_Type;
69
70#define PyDictKeys_Check(op) PyObject_TypeCheck(op, &PyDictKeys_Type)
71#define PyDictValues_Check(op) PyObject_TypeCheck(op, &PyDictValues_Type)
72#define PyDictItems_Check(op) PyObject_TypeCheck(op, &PyDictItems_Type)
73/* This excludes Values, since they are not sets. */
74# define PyDictViewSet_Check(op) \
75 (PyDictKeys_Check(op) || PyDictItems_Check(op))
76
77/* Dictionary (key, value, items) iterators */
78
79PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
80PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
81PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
82
83PyAPI_DATA(PyTypeObject) PyDictRevIterKey_Type;
84PyAPI_DATA(PyTypeObject) PyDictRevIterItem_Type;
85PyAPI_DATA(PyTypeObject) PyDictRevIterValue_Type;
86
87
88#ifndef Py_LIMITED_API
89# define Py_CPYTHON_DICTOBJECT_H
90# include "cpython/dictobject.h"
91# undef Py_CPYTHON_DICTOBJECT_H
92#endif
93
94#ifdef __cplusplus
95}
96#endif
97#endif /* !Py_DICTOBJECT_H */
98

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