We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 100c7ab commit 5fb201dCopy full SHA for 5fb201d
Objects/listobject.c
@@ -651,11 +651,18 @@ static PyObject *
651
list_item(PyObject *aa, Py_ssize_t i)
652
{
653
PyListObject *a = (PyListObject *)aa;
654
+ PyObject *item;
655
if (!valid_index(i, PyList_GET_SIZE(a))) {
656
PyErr_SetObject(PyExc_IndexError, &_Py_STR(list_err));
657
return NULL;
658
}
- PyObject *item;
659
+#ifdef Py_GIL_DISABLED
660
+ PyObject **ob_item = _Py_atomic_load_ptr(&a->ob_item);
661
+ item = _Py_atomic_load_ptr(&ob_item[i]);
662
+ if (item && _Py_TryIncrefCompare(&ob_item[i], item)) {
663
+ return item;
664
+ }
665
+#endif
666
Py_BEGIN_CRITICAL_SECTION(a);
667
#ifdef Py_GIL_DISABLED
668
if (!_Py_IsOwnedByCurrentThread((PyObject *)a) && !_PyObject_GC_IS_SHARED(a)) {
0 commit comments