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

Skip to content

Commit 0891529

Browse files
committed
Make PyDictKeysObject thread-safe
1 parent 8612230 commit 0891529

File tree

2 files changed

+231
-95
lines changed

2 files changed

+231
-95
lines changed

Include/internal/pycore_dict.h

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

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

@@ -150,6 +155,7 @@ struct _dictkeysobject {
150155
/* Number of used entries in dk_entries. */
151156
Py_ssize_t dk_nentries;
152157

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

0 commit comments

Comments
 (0)
0