Skip to content

Commit

Permalink
pythongh-112075: Iterating a dict shouldn't require locks (python#115108
Browse files Browse the repository at this point in the history
)

Makes iteration of a dict be lock free for the forward iteration case.
  • Loading branch information
DinoV authored and diegorusso committed Apr 17, 2024
1 parent 9b7fb30 commit 3b06e72
Show file tree
Hide file tree
Showing 2 changed files with 265 additions and 60 deletions.
1 change: 1 addition & 0 deletions Include/internal/pycore_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ static inline PyDictUnicodeEntry* DK_UNICODE_ENTRIES(PyDictKeysObject *dk) {
#define DICT_WATCHER_AND_MODIFICATION_MASK ((1 << (DICT_MAX_WATCHERS + DICT_WATCHED_MUTATION_BITS)) - 1)

#define DICT_VALUES_SIZE(values) ((uint8_t *)values)[-1]
#define DICT_VALUES_USED_SIZE(values) ((uint8_t *)values)[-2]

#ifdef Py_GIL_DISABLED
#define DICT_NEXT_VERSION(INTERP) \
Expand Down
Loading

0 comments on commit 3b06e72

Please sign in to comment.