Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In the free-threaded build, dictionary access hint specializations now attempt to enable deferred reference counting for resolved values owned by a different thread, reducing cross-thread reference count traffic and improving multi-threaded scalability.
Patch by Benedikt Johannes.
12 changes: 12 additions & 0 deletions 12 Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,14 +644,26 @@ specialize_dict_access_hint(
SPECIALIZATION_FAIL(base_op, SPEC_FAIL_ATTR_SPLIT_DICT);
return 0;
}
#ifdef Py_GIL_DISABLED
PyObject *value;
Py_ssize_t index = _PyDict_LookupIndexAndValue(dict, name, &value);
if (value != NULL && PyLazyImport_CheckExact(value)) {
SPECIALIZATION_FAIL(base_op, SPEC_FAIL_ATTR_MODULE_LAZY_VALUE);
return 0;
}
#else
Py_ssize_t index = _PyDict_LookupIndex(dict, name);
#endif
if (index != (uint16_t)index) {
SPECIALIZATION_FAIL(base_op,
index == DKIX_EMPTY ?
SPEC_FAIL_ATTR_NOT_IN_DICT :
SPEC_FAIL_OUT_OF_RANGE);
return 0;
}
#ifdef Py_GIL_DISABLED
maybe_enable_deferred_ref_count(value);
#endif
cache->index = (uint16_t)index;
write_u32(cache->version, tp_version);
specialize(instr, hint_op);
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.