@@ -43,6 +43,11 @@ typedef struct {
43
43
PyObject * me_value ; /* This field is only meaningful for combined tables */
44
44
} PyDictKeyEntry ;
45
45
46
+ typedef struct {
47
+ PyObject * me_key ; /* The key must be Unicode and have hash. */
48
+ PyObject * me_value ; /* This field is only meaningful for combined tables */
49
+ } PyDictUnicodeEntry ;
50
+
46
51
extern PyDictKeysObject * _PyDict_NewKeysForClass (void );
47
52
extern PyObject * _PyDict_FromKeys (PyObject * , PyObject * , PyObject * );
48
53
@@ -70,6 +75,7 @@ extern PyObject *_PyDict_Pop_KnownHash(PyObject *, PyObject *, Py_hash_t, PyObje
70
75
#define DKIX_EMPTY (-1)
71
76
#define DKIX_DUMMY (-2) /* Used internally */
72
77
#define DKIX_ERROR (-3)
78
+ #define DKIX_KEY_CHANGED (-4) /* Used internally */
73
79
74
80
typedef enum {
75
81
DICT_KEYS_GENERAL = 0 ,
@@ -114,7 +120,7 @@ struct _dictkeysobject {
114
120
Dynamically sized, SIZEOF_VOID_P is minimum. */
115
121
char dk_indices []; /* char is required to avoid strict aliasing. */
116
122
117
- /* "PyDictKeyEntry dk_entries[dk_usable ];" array follows:
123
+ /* "PyDictKeyEntry or PyDictUnicodeEntry dk_entries[USABLE_FRACTION(DK_SIZE(dk)) ];" array follows:
118
124
see the DK_ENTRIES() macro */
119
125
};
120
126
@@ -148,13 +154,20 @@ struct _dictvalues {
148
154
2 : sizeof(int32_t))
149
155
#endif
150
156
#define DK_ENTRIES (dk ) \
151
- ((PyDictKeyEntry*)(&((int8_t*)((dk)->dk_indices))[(size_t)1 << (dk)->dk_log2_index_bytes]))
157
+ (assert(dk->dk_kind == DICT_KEYS_GENERAL), (PyDictKeyEntry*)(&((int8_t*)((dk)->dk_indices))[(size_t)1 << (dk)->dk_log2_index_bytes]))
158
+ #define DK_UNICODE_ENTRIES (dk ) \
159
+ (assert(dk->dk_kind != DICT_KEYS_GENERAL), (PyDictUnicodeEntry*)(&((int8_t*)((dk)->dk_indices))[(size_t)1 << (dk)->dk_log2_index_bytes]))
160
+ #define DK_IS_UNICODE (dk ) ((dk)->dk_kind != DICT_KEYS_GENERAL)
152
161
153
162
extern uint64_t _pydict_global_version ;
154
163
155
164
#define DICT_NEXT_VERSION () (++_pydict_global_version)
156
165
157
166
extern PyObject * _PyObject_MakeDictFromInstanceAttributes (PyObject * obj , PyDictValues * values );
167
+ extern PyObject * _PyDict_FromItems (
168
+ PyObject * const * keys , Py_ssize_t keys_offset ,
169
+ PyObject * const * values , Py_ssize_t values_offset ,
170
+ Py_ssize_t length );
158
171
159
172
static inline void
160
173
_PyDictValues_AddToInsertionOrder (PyDictValues * values , Py_ssize_t ix )
0 commit comments