Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-45530: speed listobject.c's unsafe_tuple_compare() #29076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 25, 2021
Prev Previous commit
Next Next commit
Remove the new firsti vrbl - needless name proliferation.
  • Loading branch information
tim-one committed Oct 22, 2021
commit cd69e8b8af29a34065434e75eddac9109e23a8fd
8 changes: 4 additions & 4 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2207,7 +2207,7 @@ static int
unsafe_tuple_compare(PyObject *v, PyObject *w, MergeState *ms)
{
PyTupleObject *vt, *wt;
Py_ssize_t i, vlen, wlen, firsti;
Py_ssize_t i, vlen, wlen;
int k;

/* Modified from Objects/tupleobject.c:tuplerichcompare, assuming: */
Expand All @@ -2218,7 +2218,7 @@ unsafe_tuple_compare(PyObject *v, PyObject *w, MergeState *ms)

vt = (PyTupleObject *)v;
wt = (PyTupleObject *)w;
firsti = 0;
i = 0;
if (ms->first_tuple_items_resolved_it) {
/* See whether fast compares of the first elements settle it. */
k = ms->tuple_elem_compare(vt->ob_item[0], wt->ob_item[0], ms);
Expand All @@ -2234,7 +2234,7 @@ unsafe_tuple_compare(PyObject *v, PyObject *w, MergeState *ms)
* which implies, for a total order, that the first elements are
* equal. So skip them in the loop.
*/
firsti = 1;
i = 1;
ms->first_tuple_items_resolved_it = 0;
}
/* Now first_tuple_items_resolved_it was 0 on entry, or was forced to 0
Expand All @@ -2244,7 +2244,7 @@ unsafe_tuple_compare(PyObject *v, PyObject *w, MergeState *ms)

vlen = Py_SIZE(vt);
wlen = Py_SIZE(wt);
for (i = firsti; i < vlen && i < wlen; i++) {
for (; i < vlen && i < wlen; i++) {
k = PyObject_RichCompareBool(vt->ob_item[i], wt->ob_item[i], Py_EQ);
if (k < 0)
return -1;
Expand Down