8000 gh-119053: Implement the fast path for list.__getitem__ · python/cpython@f895ca9 · GitHub
[go: up one dir, main page]

Skip to content

Commit f895ca9

Browse files
committed
gh-119053: Im 8000 plement the fast path for list.__getitem__
1 parent 100c7ab commit f895ca9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Objects/listobject.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,16 @@ list_item(PyObject *aa, Py_ssize_t i)
656656
return NULL;
657657
}
658658
PyObject *item;
659+
#ifdef Py_GIL_DISABLED
660+
PyObject **ob_item = _Py_atomic_load_ptr(&a->ob_item);
661+
item = _Py_TryXGetRef(&ob_item[i]);
662+
if (item) {
663+
if (_Py_atomic_load_ptr(&ob_item[i]) == item) {
664+
return item;
665+
}
666+
Py_DECREF(item);
667+
}
668+
#endif
659669
Py_BEGIN_CRITICAL_SECTION(a);
660670
#ifdef Py_GIL_DISABLED
661671
if (!_Py_IsOwnedByCurrentThread((PyObject *)a) && !_PyObject_GC_IS_SHARED(a)) {

0 commit comments

Comments
 (0)
0