Skip to content

Commit

Permalink
Make PyDictKeysObject thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
DinoV committed Jan 30, 2024
1 parent 8612230 commit 0891529
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 95 deletions.
6 changes: 6 additions & 0 deletions Include/internal/pycore_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ struct _dictkeysobject {
/* Kind of keys */
uint8_t dk_kind;

#ifdef Py_GIL_DISABLED
/* Lock used to protect shared keys */
PyMutex dk_mutex;
#endif

/* Version number -- Reset to 0 by any modification to keys */
uint32_t dk_version;

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


/* Actual hash table of dk_size entries. It holds indices in dk_entries,
or DKIX_EMPTY(-1) or DKIX_DUMMY(-2).
Expand Down
Loading

0 comments on commit 0891529

Please sign in to comment.