Skip to content

Commit

Permalink
Try using _Py_dict_lookup_threadsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
colesbury committed Sep 14, 2024
1 parent 4321cdc commit 17d16e1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2483,17 +2483,21 @@ _PyDict_LoadGlobalStackRef(PyDictObject *globals, PyDictObject *builtins, PyObje
}

/* namespace 1: globals */
ix = _Py_dict_lookup_threadsafe_stackref(globals, key, hash, res);
PyObject *value;
ix = _Py_dict_lookup_threadsafe(globals, key, hash, &value);
if (ix == DKIX_ERROR) {
*res = PyStackRef_NULL;
return;
}
if (ix != DKIX_EMPTY && !PyStackRef_IsNull(*res)) {
if (ix != DKIX_EMPTY && value != NULL) {
*res = PyStackRef_FromPyObjectSteal(value);
return;
}

/* namespace 2: builtins */
ix = _Py_dict_lookup_threadsafe_stackref(builtins, key, hash, res);
assert(ix >= 0 || PyStackRef_IsNull(*res));
ix = _Py_dict_lookup_threadsafe(builtins, key, hash, &value);
assert(ix >= 0 || value == NULL);
*res = PyStackRef_FromPyObjectSteal(value);
}

/* Consumes references to key and value */
Expand Down

0 comments on commit 17d16e1

Please sign in to comment.