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