Skip to content

Commit

Permalink
pythongh-119053: Implement the fast path for list.__getitem__
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed May 17, 2024
1 parent 100c7ab commit f895ca9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,16 @@ list_item(PyObject *aa, Py_ssize_t i)
return NULL;
}
PyObject *item;
#ifdef Py_GIL_DISABLED
PyObject **ob_item = _Py_atomic_load_ptr(&a->ob_item);
item = _Py_TryXGetRef(&ob_item[i]);
if (item) {
if (_Py_atomic_load_ptr(&ob_item[i]) == item) {
return item;
}
Py_DECREF(item);
}
#endif
Py_BEGIN_CRITICAL_SECTION(a);
#ifdef Py_GIL_DISABLED
if (!_Py_IsOwnedByCurrentThread((PyObject *)a) && !_PyObject_GC_IS_SHARED(a)) {
Expand Down

0 comments on commit f895ca9

Please sign in to comment.