Skip to content

Commit e256c6b

Browse files
committed
Raise PyType_Modified for insertion into split dictionary
1 parent 369ce43 commit e256c6b

14 files changed

Lines changed: 1401 additions & 1422 deletions

File tree

Include/internal/pycore_dict.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ typedef struct {
9090
} PyDictUnicodeEntry;
9191

9292
extern PyDictKeysObject *_PyDict_NewKeysForClass(PyHeapTypeObject *);
93+
extern void _PyDict_RemoveKeysForClass(PyHeapTypeObject *);
94+
extern void _PyDict_SplitKeysInvalidated(PyDictKeysObject* keys);
9395
extern PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *);
9496

9597
/* Implementations of the `|` and `|=` operators for dict, used by the
@@ -239,6 +241,17 @@ struct _dictkeysobject {
239241
see the DK_ENTRIES() / DK_UNICODE_ENTRIES() functions below */
240242
};
241243

244+
struct _instancekeysobject {
245+
PyTypeObject* dsk_owning_type;
246+
struct _dictkeysobject dsk_keys;
247+
};
248+
249+
static inline struct _instancekeysobject *_PyDictKeys_AsSharedKeys(struct _dictkeysobject *keys)
250+
{
251+
assert(keys->dk_kind == DICT_KEYS_SPLIT);
252+
return _Py_CONTAINER_OF(keys, struct _instancekeysobject, dsk_keys);
253+
}
254+
242255
/* This must be no more than 250, for the prefix size to fit in one byte. */
243256
#define SHARED_KEYS_MAX_SIZE 30
244257
#define NEXT_LOG2_SHARED_KEYS_MAX_SIZE 6

Include/internal/pycore_opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_typeobject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ extern int _PyType_AddMethod(PyTypeObject *, PyMethodDef *);
148148
extern void _PyType_SetFlagsRecursive(PyTypeObject *self, unsigned long mask,
149149
unsigned long flags);
150150

151+
// Raise PyType_Modified with the type lock already held.
152+
extern void _PyType_Modified_Unlocked(PyTypeObject *type);
153+
151154
PyAPI_FUNC(void) _PyType_SetVersion(PyTypeObject *tp, unsigned int version);
152155
PyTypeObject *_PyType_LookupByVersion(unsigned int version);
153156

0 commit comments

Comments
 (0)