Skip to content

Commit 82212b3

Browse files
Improve performance in specialize_dict_access_hint() via adding specialization for PY_GIL_DISABLED
1 parent 837166f commit 82212b3

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Python/specialize.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,14 +644,22 @@ specialize_dict_access_hint(
644644
SPECIALIZATION_FAIL(base_op, SPEC_FAIL_ATTR_SPLIT_DICT);
645645
return 0;
646646
}
647+
#ifdef Py_GIL_DISABLED
648+
PyObject *value;
649+
Py_ssize_t index = _PyDict_LookupIndexAndValue((PyDictObject *)globals, name, &value);
650+
#else
647651
Py_ssize_t index = _PyDict_LookupIndex(dict, name);
652+
#endif
648653
if (index != (uint16_t)index) {
649654
SPECIALIZATION_FAIL(base_op,
650655
index == DKIX_EMPTY ?
651656
SPEC_FAIL_ATTR_NOT_IN_DICT :
652657
SPEC_FAIL_OUT_OF_RANGE);
653658
return 0;
654659
}
660+
#ifdef Py_GIL_DISABLED
661+
maybe_enable_deferred_ref_count(value);
662+
#endif
655663
cache->index = (uint16_t)index;
656664
write_u32(cache->version, tp_version);
657665
specialize(instr, hint_op);

0 commit comments

Comments
 (0)