@@ -1165,18 +1165,11 @@ unsafe_float_compare(PyObject *v, PyObject *w, CompareFuncs compare_funcs){
11651165 return PyFloat_AS_DOUBLE (v ) < PyFloat_AS_DOUBLE (w );
11661166}
11671167
1168- /* Tuple compare: compare any two non-empty tuples.
1169- * This is the most complicated special case: since the tuple elements themselves
1170- * must of course be compared, we can optimize on two levels. Namely, we make
1171- * the same homogeneity assumptions about the first elements of the tuples in
1172- * our list as we do about the list elements themselves. We then replace the call to
1173- * PyObject_RichCompareBool within the tuple comparison with special case compare,
1174- * based on which assumptions the first elements of the tuples satisfy.
1175- *
1176- * Note that we must therefore ensure assumptions in both unsafe_tuple_compare and
1177- * compare_funcs.tuple_elem_compare are satisfied. If the first elements are not all
1178- * homogeneous, we can always set
1179- * compare_funcs.tuple_elem_compare = safe_object_compare. */
1168+ /* Tuple compare: compare any two non-empty tuples, using
1169+ * compare_funcs.tuple_elem_compare to compare the first elements, which is set
1170+ * using the same pre-sort check as we use for compare_funcs.key_compare,
1171+ * but run on the list [x[0] for x in L]. This allows us to optimize compares
1172+ * on two levels as long as [x[0] for x in L] is type-homogeneous. */
11801173static int
11811174unsafe_tuple_compare (PyObject * v , PyObject * w , CompareFuncs compare_funcs )
11821175{
0 commit comments