8000 Make PyDictKeysObject thread-safe · python/cpython@b9f691a · GitHub
[go: up one dir, main page]

Skip to content

Commit b9f691a

Browse files
committed
Make PyDictKeysObject thread-safe
1 parent 11ac6f5 commit b9f691a

File tree

2 files changed

+228
-96
lines changed

2 files changed

+228
-96
lines changed

Include/internal/pycore_dict.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ struct _dictkeysobject {
142142
/* Kind of keys */
143143
uint8_t dk_kind;
144144

145+
#ifdef Py_GIL_DISABLED
146+
/* Lock used to protect shared keys */
147+
PyMutex dk_mutex;
148+
#endif
149+
145150
/* Version number -- Reset to 0 by any modification to keys */
146151
uint32_t dk_version;
147152

@@ -151,6 +156,7 @@ struct _dictkeysobject {
151156
/* Number of used entries in dk_entries. */
152157
Py_ssize_t dk_nentries;
153158

159+
154160
/* Actual hash table of dk_size entries. It holds indices in dk_entries,
155161
or DKIX_EMPTY(-1) or DKIX_DUMMY(-2).
156162

0 commit comments

Comments
 (0)
0