Mercurial > cpython-lru_cache-weakref
annotate Include/dictobject.h @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | 3c9232a684ae |
| children | 910986542a75 |
| rev | line source |
|---|---|
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1 #ifndef Py_DICTOBJECT_H |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2 #define Py_DICTOBJECT_H |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
3 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
4 extern "C" { |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
5 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
6 |
| 145 | 7 |
|
5508
3643f19d5ca1
Subsumed mappingobject.h in dictobject.h.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
8 /* Dictionary object type -- mapping from hashable object to object */ |
|
3643f19d5ca1
Subsumed mappingobject.h in dictobject.h.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
9 |
|
28946
dbdeb734ff97
Add a reference to dictnotes.txt. It does no good if you don't know it's
Raymond Hettinger <python@rcn.com>
parents:
26599
diff
changeset
|
10 /* The distribution includes a separate file, Objects/dictnotes.txt, |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
11 describing explorations into dictionary design and optimization. |
|
28946
dbdeb734ff97
Add a reference to dictnotes.txt. It does no good if you don't know it's
Raymond Hettinger <python@rcn.com>
parents:
26599
diff
changeset
|
12 It covers typical dictionary use patterns, the parameters for |
|
dbdeb734ff97
Add a reference to dictnotes.txt. It does no good if you don't know it's
Raymond Hettinger <python@rcn.com>
parents:
26599
diff
changeset
|
13 tuning dictionaries, and several ideas for possible optimizations. |
|
dbdeb734ff97
Add a reference to dictnotes.txt. It does no good if you don't know it's
Raymond Hettinger <python@rcn.com>
parents:
26599
diff
changeset
|
14 */ |
|
dbdeb734ff97
Add a reference to dictnotes.txt. It does no good if you don't know it's
Raymond Hettinger <python@rcn.com>
parents:
26599
diff
changeset
|
15 |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
16 /* |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
17 There are three kinds of slots in the table: |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
18 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
19 1. Unused. me_key == me_value == NULL |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
20 Does not hold an active (key, value) pair now and never did. Unused can |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
21 transition to Active upon key insertion. This is the only case in which |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
22 me_key is NULL, and is each slot's initial state. |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
23 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
24 2. Active. me_key != NULL and me_key != dummy and me_value != NULL |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
25 Holds an active (key, value) pair. Active can transition to Dummy upon |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
26 key deletion. This is the only case in which me_value != NULL. |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
27 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
28 3. Dummy. me_key == dummy and me_value == NULL |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
29 Previously held an active (key, value) pair, but that was deleted and an |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
30 active pair has not yet overwritten the slot. Dummy can transition to |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
31 Active upon key insertion. Dummy slots cannot be made Unused again |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
32 (cannot have me_key set to NULL), else the probe sequence in case of |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
33 collision would have no way to know they were once active. |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
34 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
35 Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
36 hold a search finger. The me_hash field of Unused or Dummy slots has no |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
37 meaning otherwise. |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
38 */ |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
39 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
40 /* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
41 * allocated directly in the dict object (in the ma_smalltable member). |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
42 * It must be a power of 2, and at least 4. 8 allows dicts with no more |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
43 * than 5 active entries to live in ma_smalltable (and so avoid an |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
44 * additional malloc); instrumentation suggested this suffices for the |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
45 * majority of dicts (consisting mostly of usually-small instance dicts and |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
46 * usually-small dicts created to pass keyword arguments). |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
47 */ |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65494
diff
changeset
|
48 #ifndef Py_LIMITED_API |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
49 #define PyDict_MINSIZE 8 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
50 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
51 typedef struct { |
|
65494
e8969fb822fc
make hashes always the size of pointers; introduce Py_hash_t #9778
Benjamin Peterson <benjamin@python.org>
parents:
61466
diff
changeset
|
52 /* Cached hash code of me_key. */ |
|
e8969fb822fc
make hashes always the size of pointers; introduce Py_hash_t #9778
Benjamin Peterson <benjamin@python.org>
parents:
61466
diff
changeset
|
53 Py_hash_t me_hash; |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
54 PyObject *me_key; |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
55 PyObject *me_value; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
56 } PyDictEntry; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
57 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
58 /* |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
59 To ensure the lookup algorithm terminates, there must be at least one Unused |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
60 slot (NULL key) in the table. |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
61 The value ma_fill is the number of non-NULL keys (sum of Active and Dummy); |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
62 ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
63 values == the number of Active items). |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
64 To avoid slowing down lookups on a near-full table, we resize the table when |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
65 it's two-thirds full. |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
66 */ |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
67 typedef struct _dictobject PyDictObject; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
68 struct _dictobject { |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
69 PyObject_HEAD |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
70 Py_ssize_t ma_fill; /* # Active + # Dummy */ |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
71 Py_ssize_t ma_used; /* # Active */ |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
72 |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
73 /* The table contains ma_mask + 1 slots, and that's a power of 2. |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
74 * We store the mask instead of the size because the mask is more |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
75 * frequently needed. |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
76 */ |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
77 Py_ssize_t ma_mask; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
78 |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
79 /* ma_table points to ma_smalltable for small tables, else to |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
80 * additional malloc'ed memory. ma_table is never NULL! This rule |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
81 * saves repeated runtime null-tests in the workhorse getitem and |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
82 * setitem calls. |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
83 */ |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
84 PyDictEntry *ma_table; |
|
65494
e8969fb822fc
make hashes always the size of pointers; introduce Py_hash_t #9778
Benjamin Peterson <benjamin@python.org>
parents:
61466
diff
changeset
|
85 PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, Py_hash_t hash); |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
86 PyDictEntry ma_smalltable[PyDict_MINSIZE]; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
87 }; |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65494
diff
changeset
|
88 #endif /* Py_LIMITED_API */ |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
89 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
90 PyAPI_DATA(PyTypeObject) PyDict_Type; |
|
44061
0cc552ab76bd
Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
91 PyAPI_DATA(PyTypeObject) PyDictIterKey_Type; |
|
0cc552ab76bd
Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
92 PyAPI_DATA(PyTypeObject) PyDictIterValue_Type; |
|
0cc552ab76bd
Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
93 PyAPI_DATA(PyTypeObject) PyDictIterItem_Type; |
|
0cc552ab76bd
Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
94 PyAPI_DATA(PyTypeObject) PyDictKeys_Type; |
|
0cc552ab76bd
Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
95 PyAPI_DATA(PyTypeObject) PyDictItems_Type; |
|
0cc552ab76bd
Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
96 PyAPI_DATA(PyTypeObject) PyDictValues_Type; |
|
5508
3643f19d5ca1
Subsumed mappingobject.h in dictobject.h.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
97 |
|
40909
f2f0b41f270d
Merged revisions 53875-53911 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40893
diff
changeset
|
98 #define PyDict_Check(op) \ |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44349
diff
changeset
|
99 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) |
|
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44349
diff
changeset
|
100 #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) |
|
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44349
diff
changeset
|
101 #define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type) |
|
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44349
diff
changeset
|
102 #define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type) |
|
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
44349
diff
changeset
|
103 #define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type) |
|
44061
0cc552ab76bd
Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
104 /* This excludes Values, since they are not sets. */ |
|
0cc552ab76bd
Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
105 # define PyDictViewSet_Check(op) \ |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
106 (PyDictKeys_Check(op) || PyDictItems_Check(op)) |
|
44061
0cc552ab76bd
Added all PyTypeObjects to the appropriate header files.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
107 |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
790
diff
changeset
|
108 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
109 PyAPI_FUNC(PyObject *) PyDict_New(void); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
110 PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); |
|
47410
1bdf07409403
Added missing prototype for PyDict_GetItemWithError().
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
44351
diff
changeset
|
111 PyAPI_FUNC(PyObject *) PyDict_GetItemWithError(PyObject *mp, PyObject *key); |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
112 PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
113 PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
114 PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
115 PyAPI_FUNC(int) PyDict_Next( |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
116 PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value); |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65494
diff
changeset
|
117 #ifndef Py_LIMITED_API |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
118 PyAPI_FUNC(int) _PyDict_Next( |
|
65494
e8969fb822fc
make hashes always the size of pointers; introduce Py_hash_t #9778
Benjamin Peterson <benjamin@python.org>
parents:
61466
diff
changeset
|
119 PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash); |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65494
diff
changeset
|
120 #endif |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
121 PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
122 PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
123 PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp); |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
31269
diff
changeset
|
124 PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp); |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
125 PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); |
|
31019
b2fd7af17186
Expose dict_contains() and PyDict_Contains() with is about 10% faster
Raymond Hettinger <python@rcn.com>
parents:
28946
diff
changeset
|
126 PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65494
diff
changeset
|
127 #ifndef Py_LIMITED_API |
|
65494
e8969fb822fc
make hashes always the size of pointers; introduce Py_hash_t #9778
Benjamin Peterson <benjamin@python.org>
parents:
61466
diff
changeset
|
128 PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, Py_hash_t hash); |
|
44349
4dc01402d78a
Merged revisions 59541-59561 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44061
diff
changeset
|
129 PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); |
|
52291
94bd0666ffa7
Merged revisions 70546 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
47410
diff
changeset
|
130 PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp); |
|
60931
79128efe8a99
prevent the dict constructor from accepting non-string keyword args #8419
Benjamin Peterson <benjamin@python.org>
parents:
52291
diff
changeset
|
131 PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp); |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
65494
diff
changeset
|
132 #endif |
|
21348
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
133 |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
134 /* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
135 PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); |
|
12126
e6214ad2a60c
Add PyDict_Copy() function to C API for dicts. It returns a new
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
9586
diff
changeset
|
136 |
|
21348
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
137 /* PyDict_Merge updates/merges from a mapping object (an object that |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
138 supports PyMapping_Keys() and PyObject_GetItem()). If override is true, |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
139 the last occurrence of a key wins, else the first. The Python |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
140 dict.update(other) is equivalent to PyDict_Merge(dict, other, 1). |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
141 */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
142 PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
143 PyObject *other, |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
144 int override); |
|
21348
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
145 |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
146 /* PyDict_MergeFromSeq2 updates/merges from an iterable object producing |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
147 iterable objects of length 2. If override is true, the last occurrence |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
148 of a key wins, else the first. The Python dict constructor dict(seq2) |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
149 is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1). |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
150 */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
151 PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d, |
|
61467
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
152 PyObject *seq2, |
|
f197407bdba2
Recorded merge of revisions 81032 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
52291
diff
changeset
|
153 int override); |
|
5508
3643f19d5ca1
Subsumed mappingobject.h in dictobject.h.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
154 |
|
26599
ecea8410178e
Constify char* API. Fixes #651363. 2.2 candidate.
Martin v. Löwis <martin@v.loewis.de>
parents:
24752
diff
changeset
|
155 PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key); |
|
ecea8410178e
Constify char* API. Fixes #651363. 2.2 candidate.
Martin v. Löwis <martin@v.loewis.de>
parents:
24752
diff
changeset
|
156 PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); |
|
ecea8410178e
Constify char* API. Fixes #651363. 2.2 candidate.
Martin v. Löwis <martin@v.loewis.de>
parents:
24752
diff
changeset
|
157 PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key); |
| 6 | 158 |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
159 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
160 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
161 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
162 #endif /* !Py_DICTOBJECT_H */ |
