Mercurial > cpython-lru_cache-weakref
annotate Include/dictobject.h @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | b36cb4602e21 |
| children |
| 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, |
|
38499
494cab563c11
Convert relevant dict internals to Py_ssize_t.
Tim Peters <tim.peters@gmail.com>
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 */ |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
48 #define PyDict_MINSIZE 8 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
49 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
50 typedef struct { |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
51 /* Cached hash code of me_key. Note that hash codes are C longs. |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
52 * We have to use Py_ssize_t instead because dict_popitem() abuses |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
53 * me_hash to hold a search finger. |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
54 */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
55 Py_ssize_t me_hash; |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
56 PyObject *me_key; |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
57 PyObject *me_value; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
58 } PyDictEntry; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
59 |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
60 /* |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
61 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
|
62 slot (NULL key) in the table. |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
63 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
|
64 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
|
65 values == the number of Active items). |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
66 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
|
67 it's two-thirds full. |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
68 */ |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
69 typedef struct _dictobject PyDictObject; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
70 struct _dictobject { |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
71 PyObject_HEAD |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
72 Py_ssize_t ma_fill; /* # Active + # Dummy */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
73 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
|
74 |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
75 /* The table contains ma_mask + 1 slots, and that's a power of 2. |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
76 * We store the mask instead of the size because the mask is more |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
77 * frequently needed. |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
78 */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
79 Py_ssize_t ma_mask; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
80 |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
81 /* ma_table points to ma_smalltable for small tables, else to |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
82 * additional malloc'ed memory. ma_table is never NULL! This rule |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
83 * saves repeated runtime null-tests in the workhorse getitem and |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
84 * setitem calls. |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
85 */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
86 PyDictEntry *ma_table; |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
87 PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash); |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
88 PyDictEntry ma_smalltable[PyDict_MINSIZE]; |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
89 }; |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
90 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
91 PyAPI_DATA(PyTypeObject) PyDict_Type; |
|
58256
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
92 PyAPI_DATA(PyTypeObject) PyDictIterKey_Type; |
|
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
93 PyAPI_DATA(PyTypeObject) PyDictIterValue_Type; |
|
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
94 PyAPI_DATA(PyTypeObject) PyDictIterItem_Type; |
|
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
95 PyAPI_DATA(PyTypeObject) PyDictKeys_Type; |
|
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
96 PyAPI_DATA(PyTypeObject) PyDictItems_Type; |
|
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
97 PyAPI_DATA(PyTypeObject) PyDictValues_Type; |
|
5508
3643f19d5ca1
Subsumed mappingobject.h in dictobject.h.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
98 |
|
40908
d01bd37bf5ce
Variation of patch # 1624059 to speed up checking if an object is a subclass
Neal Norwitz <nnorwitz@gmail.com>
parents:
40864
diff
changeset
|
99 #define PyDict_Check(op) \ |
|
44350
26384b8180c7
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents:
44339
diff
changeset
|
100 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) |
|
26384b8180c7
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents:
44339
diff
changeset
|
101 #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) |
|
58256
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
102 #define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type) |
|
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
103 #define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type) |
|
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
104 #define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type) |
|
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
105 /* This excludes Values, since they are not sets. */ |
|
d9805a96351c
Issue #1967: Backport dictionary views.
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
52288
diff
changeset
|
106 # define PyDictViewSet_Check(op) \ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
58256
diff
changeset
|
107 (PyDictKeys_Check(op) || PyDictItems_Check(op)) |
|
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); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
111 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
|
112 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
|
113 PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
114 PyAPI_FUNC(int) PyDict_Next( |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
115 PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value); |
|
40864
b0f8e9b0cc19
Extend work on revision 52962: Eliminate redundant calls to PyObject_Hash().
Raymond Hettinger <python@rcn.com>
parents:
38499
diff
changeset
|
116 PyAPI_FUNC(int) _PyDict_Next( |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
117 PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash); |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
118 PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
119 PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
120 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
|
121 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
|
122 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
|
123 PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); |
|
40864
b0f8e9b0cc19
Extend work on revision 52962: Eliminate redundant calls to PyObject_Hash().
Raymond Hettinger <python@rcn.com>
parents:
38499
diff
changeset
|
124 PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash); |
|
44339
7ac117b3be37
Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary.
Raymond Hettinger <python@rcn.com>
parents:
42334
diff
changeset
|
125 PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); |
|
52288
0e498a9fde3c
Issue #4688: Add a heuristic so that tuples and dicts containing only
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
126 PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp); |
|
21348
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
127 |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
128 /* 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
|
129 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
|
130 |
|
21348
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
131 /* 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
|
132 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
|
133 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
|
134 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
|
135 */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
136 PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
137 PyObject *other, |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
138 int override); |
|
21348
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
139 |
|
12310d643d8d
SF bug #491415 PyDict_UpdateFromSeq2() unused
Tim Peters <tim.peters@gmail.com>
parents:
19150
diff
changeset
|
140 /* 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
|
141 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
|
142 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
|
143 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
|
144 */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22956
diff
changeset
|
145 PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d, |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
146 PyObject *seq2, |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
44350
diff
changeset
|
147 int override); |
|
5508
3643f19d5ca1
Subsumed mappingobject.h in dictobject.h.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
148 |
|
26599
ecea8410178e
Constify char* API. Fixes #651363. 2.2 candidate.
Martin v. Löwis <martin@v.loewis.de>
parents:
24752
diff
changeset
|
149 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
|
150 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
|
151 PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key); |
| 6 | 152 |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
153 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
154 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
155 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
156 #endif /* !Py_DICTOBJECT_H */ |
