@@ -43,6 +43,11 @@ typedef struct {
4343 PyObject * me_value ; /* This field is only meaningful for combined tables */
4444} PyDictKeyEntry ;
4545
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+
4651extern PyDictKeysObject * _PyDict_NewKeysForClass (void );
4752extern PyObject * _PyDict_FromKeys (PyObject * , PyObject * , PyObject * );
4853
@@ -70,6 +75,7 @@ extern PyObject *_PyDict_Pop_KnownHash(PyObject *, PyObject *, Py_hash_t, PyObje
7075#define DKIX_EMPTY (-1)
7176#define DKIX_DUMMY (-2) /* Used internally */
7277#define DKIX_ERROR (-3)
78+ #define DKIX_KEY_CHANGED (-4) /* Used internally */
7379
7480typedef enum {
7581 DICT_KEYS_GENERAL = 0 ,
@@ -114,7 +120,7 @@ struct _dictkeysobject {
114120 Dynamically sized, SIZEOF_VOID_P is minimum. */
115121 char dk_indices []; /* char is required to avoid strict aliasing. */
116122
117- /* "PyDictKeyEntry dk_entries[dk_usable ];" array follows:
123+ /* "PyDictKeyEntry or PyDictUnicodeEntry dk_entries[USABLE_FRACTION(DK_SIZE(dk)) ];" array follows:
118124 see the DK_ENTRIES() macro */
119125};
120126
@@ -148,13 +154,20 @@ struct _dictvalues {
148154 2 : sizeof(int32_t))
149155#endif
150156#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)
152161
153162extern uint64_t _pydict_global_version ;
154163
155164#define DICT_NEXT_VERSION () (++_pydict_global_version)
156165
157166extern 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 );
158171
159172static inline void
160173_PyDictValues_AddToInsertionOrder (PyDictValues * values , Py_ssize_t ix )
0 commit comments