7#include "nuitka/prelude.h"
12#if PYTHON_VERSION < 0x300
13static PyObject *COMPARE_LT_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
14 CHECK_OBJECT(operand1);
15 assert(PyInt_CheckExact(operand1));
16 CHECK_OBJECT(operand2);
17 assert(PyInt_CheckExact(operand2));
19 const long a = PyInt_AS_LONG(operand1);
20 const long b = PyInt_AS_LONG(operand2);
25 PyObject *result = BOOL_FROM(r);
26 Py_INCREF_IMMORTAL(result);
30#if PYTHON_VERSION < 0x300
31static bool COMPARE_LT_CBOOL_INT_INT(PyObject *operand1, PyObject *operand2) {
32 CHECK_OBJECT(operand1);
33 assert(PyInt_CheckExact(operand1));
34 CHECK_OBJECT(operand2);
35 assert(PyInt_CheckExact(operand2));
37 const long a = PyInt_AS_LONG(operand1);
38 const long b = PyInt_AS_LONG(operand2);
49PyObject *RICH_COMPARE_LT_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
51#if PYTHON_VERSION < 0x300
52 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
53 return COMPARE_LT_OBJECT_INT_INT(operand1, operand2);
57#if PYTHON_VERSION < 0x300
58 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
62 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
67 PyTypeObject *type1 = Py_TYPE(operand1);
68 PyTypeObject *type2 = Py_TYPE(operand2);
70#if PYTHON_VERSION < 0x300
72 if (type1 == type2 && !PyInstance_Check(operand1)) {
74 richcmpfunc frich = TP_RICHCOMPARE(type1);
77 PyObject *result = (*frich)(operand1, operand2, Py_LT);
79 if (result != Py_NotImplemented) {
80 Py_LeaveRecursiveCall();
85 Py_DECREF_IMMORTAL(result);
89 cmpfunc fcmp = type1->tp_compare;
92 int c = (*fcmp)(operand1, operand2);
93 c = adjust_tp_compare(c);
95 Py_LeaveRecursiveCall();
121 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
125 PyObject *result = BOOL_FROM(r);
126 Py_INCREF_IMMORTAL(result);
134 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
135 f = TP_RICHCOMPARE(type2);
138 PyObject *result = (*f)(operand2, operand1, Py_GT);
140 if (result != Py_NotImplemented) {
141 Py_LeaveRecursiveCall();
146 Py_DECREF_IMMORTAL(result);
150 f = TP_RICHCOMPARE(type1);
152 PyObject *result = (*f)(operand1, operand2, Py_LT);
154 if (result != Py_NotImplemented) {
155 Py_LeaveRecursiveCall();
160 Py_DECREF_IMMORTAL(result);
163 f = TP_RICHCOMPARE(type2);
165 PyObject *result = (*f)(operand2, operand1, Py_GT);
167 if (result != Py_NotImplemented) {
168 Py_LeaveRecursiveCall();
173 Py_DECREF_IMMORTAL(result);
178 if (PyInstance_Check(operand1)) {
179 cmpfunc fcmp = type1->tp_compare;
180 c = (*fcmp)(operand1, operand2);
181 }
else if (PyInstance_Check(operand2)) {
182 cmpfunc fcmp = type2->tp_compare;
183 c = (*fcmp)(operand1, operand2);
185 c = try_3way_compare(operand1, operand2);
189 if (type1 == type2) {
190 Py_uintptr_t aa = (Py_uintptr_t)operand1;
191 Py_uintptr_t bb = (Py_uintptr_t)operand2;
193 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
194 }
else if (operand1 == Py_None) {
197 }
else if (operand2 == Py_None) {
200 }
else if (PyNumber_Check(operand1)) {
203 if (PyNumber_Check(operand2)) {
205 Py_uintptr_t aa = (Py_uintptr_t)type1;
206 Py_uintptr_t bb = (Py_uintptr_t)type2;
208 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
212 }
else if (PyNumber_Check(operand2)) {
216 int s = strcmp(type1->tp_name, type2->tp_name);
224 Py_uintptr_t aa = (Py_uintptr_t)type1;
225 Py_uintptr_t bb = (Py_uintptr_t)type2;
227 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
232 Py_LeaveRecursiveCall();
234 if (unlikely(c <= -2)) {
260 PyObject *result = BOOL_FROM(r);
261 Py_INCREF_IMMORTAL(result);
264 bool checked_reverse_op =
false;
267 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
268 f = TP_RICHCOMPARE(type2);
271 checked_reverse_op =
true;
273 PyObject *result = (*f)(operand2, operand1, Py_GT);
275 if (result != Py_NotImplemented) {
276 Py_LeaveRecursiveCall();
281 Py_DECREF_IMMORTAL(result);
285 f = TP_RICHCOMPARE(type1);
288 PyObject *result = (*f)(operand1, operand2, Py_LT);
290 if (result != Py_NotImplemented) {
291 Py_LeaveRecursiveCall();
296 Py_DECREF_IMMORTAL(result);
299 if (checked_reverse_op ==
false) {
300 f = TP_RICHCOMPARE(type2);
303 PyObject *result = (*f)(operand2, operand1, Py_GT);
305 if (result != Py_NotImplemented) {
306 Py_LeaveRecursiveCall();
311 Py_DECREF_IMMORTAL(result);
315 Py_LeaveRecursiveCall();
321 bool r = operand1 == operand2;
322 PyObject *result = BOOL_FROM(r);
323 Py_INCREF_IMMORTAL(result);
327 bool r = operand1 != operand2;
328 PyObject *result = BOOL_FROM(r);
329 Py_INCREF_IMMORTAL(result);
333#if PYTHON_VERSION < 0x360
334 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < %s()", type1->tp_name, type2->tp_name);
336 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and '%s'", type1->tp_name,
345nuitka_bool RICH_COMPARE_LT_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
347#if PYTHON_VERSION < 0x300
348 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
349 return COMPARE_LT_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
353#if PYTHON_VERSION < 0x300
354 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
355 return NUITKA_BOOL_EXCEPTION;
358 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
359 return NUITKA_BOOL_EXCEPTION;
363 PyTypeObject *type1 = Py_TYPE(operand1);
364 PyTypeObject *type2 = Py_TYPE(operand2);
366#if PYTHON_VERSION < 0x300
368 if (type1 == type2 && !PyInstance_Check(operand1)) {
370 richcmpfunc frich = TP_RICHCOMPARE(type1);
373 PyObject *result = (*frich)(operand1, operand2, Py_LT);
375 if (result != Py_NotImplemented) {
376 Py_LeaveRecursiveCall();
378 if (unlikely(result == NULL)) {
379 return NUITKA_BOOL_EXCEPTION;
383 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
389 Py_DECREF_IMMORTAL(result);
393 cmpfunc fcmp = type1->tp_compare;
396 int c = (*fcmp)(operand1, operand2);
397 c = adjust_tp_compare(c);
399 Py_LeaveRecursiveCall();
402 return NUITKA_BOOL_EXCEPTION;
425 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
429 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
438 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
439 f = TP_RICHCOMPARE(type2);
442 PyObject *result = (*f)(operand2, operand1, Py_GT);
444 if (result != Py_NotImplemented) {
445 Py_LeaveRecursiveCall();
447 if (unlikely(result == NULL)) {
448 return NUITKA_BOOL_EXCEPTION;
452 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
458 Py_DECREF_IMMORTAL(result);
462 f = TP_RICHCOMPARE(type1);
464 PyObject *result = (*f)(operand1, operand2, Py_LT);
466 if (result != Py_NotImplemented) {
467 Py_LeaveRecursiveCall();
469 if (unlikely(result == NULL)) {
470 return NUITKA_BOOL_EXCEPTION;
474 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
480 Py_DECREF_IMMORTAL(result);
483 f = TP_RICHCOMPARE(type2);
485 PyObject *result = (*f)(operand2, operand1, Py_GT);
487 if (result != Py_NotImplemented) {
488 Py_LeaveRecursiveCall();
490 if (unlikely(result == NULL)) {
491 return NUITKA_BOOL_EXCEPTION;
495 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
501 Py_DECREF_IMMORTAL(result);
506 if (PyInstance_Check(operand1)) {
507 cmpfunc fcmp = type1->tp_compare;
508 c = (*fcmp)(operand1, operand2);
509 }
else if (PyInstance_Check(operand2)) {
510 cmpfunc fcmp = type2->tp_compare;
511 c = (*fcmp)(operand1, operand2);
513 c = try_3way_compare(operand1, operand2);
517 if (type1 == type2) {
518 Py_uintptr_t aa = (Py_uintptr_t)operand1;
519 Py_uintptr_t bb = (Py_uintptr_t)operand2;
521 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
522 }
else if (operand1 == Py_None) {
525 }
else if (operand2 == Py_None) {
528 }
else if (PyNumber_Check(operand1)) {
531 if (PyNumber_Check(operand2)) {
533 Py_uintptr_t aa = (Py_uintptr_t)type1;
534 Py_uintptr_t bb = (Py_uintptr_t)type2;
536 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
540 }
else if (PyNumber_Check(operand2)) {
544 int s = strcmp(type1->tp_name, type2->tp_name);
552 Py_uintptr_t aa = (Py_uintptr_t)type1;
553 Py_uintptr_t bb = (Py_uintptr_t)type2;
555 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
560 Py_LeaveRecursiveCall();
562 if (unlikely(c <= -2)) {
563 return NUITKA_BOOL_EXCEPTION;
588 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
592 bool checked_reverse_op =
false;
595 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
596 f = TP_RICHCOMPARE(type2);
599 checked_reverse_op =
true;
601 PyObject *result = (*f)(operand2, operand1, Py_GT);
603 if (result != Py_NotImplemented) {
604 Py_LeaveRecursiveCall();
606 if (unlikely(result == NULL)) {
607 return NUITKA_BOOL_EXCEPTION;
611 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
617 Py_DECREF_IMMORTAL(result);
621 f = TP_RICHCOMPARE(type1);
624 PyObject *result = (*f)(operand1, operand2, Py_LT);
626 if (result != Py_NotImplemented) {
627 Py_LeaveRecursiveCall();
629 if (unlikely(result == NULL)) {
630 return NUITKA_BOOL_EXCEPTION;
634 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
640 Py_DECREF_IMMORTAL(result);
643 if (checked_reverse_op ==
false) {
644 f = TP_RICHCOMPARE(type2);
647 PyObject *result = (*f)(operand2, operand1, Py_GT);
649 if (result != Py_NotImplemented) {
650 Py_LeaveRecursiveCall();
652 if (unlikely(result == NULL)) {
653 return NUITKA_BOOL_EXCEPTION;
657 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
663 Py_DECREF_IMMORTAL(result);
667 Py_LeaveRecursiveCall();
673 bool r = operand1 == operand2;
674 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
679 bool r = operand1 != operand2;
680 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
685#if PYTHON_VERSION < 0x360
686 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < %s()", type1->tp_name, type2->tp_name);
688 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and '%s'", type1->tp_name,
691 return NUITKA_BOOL_EXCEPTION;
696#if PYTHON_VERSION < 0x300
697static PyObject *COMPARE_LT_OBJECT_STR_STR(PyObject *operand1, PyObject *operand2) {
698 CHECK_OBJECT(operand1);
699 assert(PyString_CheckExact(operand1));
700 CHECK_OBJECT(operand2);
701 assert(PyString_CheckExact(operand2));
703 PyStringObject *a = (PyStringObject *)operand1;
704 PyStringObject *b = (PyStringObject *)operand2;
707 if (operand1 == operand2) {
711 PyObject *result = BOOL_FROM(r);
712 Py_INCREF_IMMORTAL(result);
716 Py_ssize_t len_a = Py_SIZE(operand1);
717 Py_ssize_t len_b = Py_SIZE(operand2);
719 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
723 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
726 c = memcmp(a->ob_sval, b->ob_sval, min_len);
733 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
739 PyObject *result = BOOL_FROM(c != 0);
740 Py_INCREF_IMMORTAL(result);
744#if PYTHON_VERSION < 0x300
746PyObject *RICH_COMPARE_LT_OBJECT_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
748 if (Py_TYPE(operand1) == &PyString_Type) {
749 return COMPARE_LT_OBJECT_STR_STR(operand1, operand2);
752#if PYTHON_VERSION < 0x300
753 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
757 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
762 PyTypeObject *type1 = Py_TYPE(operand1);
764#if PYTHON_VERSION < 0x300
766 if (type1 == &PyString_Type && !0) {
768 richcmpfunc frich = PyString_Type.tp_richcompare;
771 PyObject *result = (*frich)(operand1, operand2, Py_LT);
773 if (result != Py_NotImplemented) {
774 Py_LeaveRecursiveCall();
779 Py_DECREF_IMMORTAL(result);
786 int c = (*fcmp)(operand1, operand2);
787 c = adjust_tp_compare(c);
789 Py_LeaveRecursiveCall();
815 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
819 PyObject *result = BOOL_FROM(r);
820 Py_INCREF_IMMORTAL(result);
828 if (type1 != &PyString_Type && 0) {
829 f = PyString_Type.tp_richcompare;
832 PyObject *result = (*f)(operand2, operand1, Py_GT);
834 if (result != Py_NotImplemented) {
835 Py_LeaveRecursiveCall();
840 Py_DECREF_IMMORTAL(result);
844 f = TP_RICHCOMPARE(type1);
846 PyObject *result = (*f)(operand1, operand2, Py_LT);
848 if (result != Py_NotImplemented) {
849 Py_LeaveRecursiveCall();
854 Py_DECREF_IMMORTAL(result);
857 f = PyString_Type.tp_richcompare;
859 PyObject *result = (*f)(operand2, operand1, Py_GT);
861 if (result != Py_NotImplemented) {
862 Py_LeaveRecursiveCall();
867 Py_DECREF_IMMORTAL(result);
872 if (PyInstance_Check(operand1)) {
873 cmpfunc fcmp = type1->tp_compare;
874 c = (*fcmp)(operand1, operand2);
877 c = (*fcmp)(operand1, operand2);
879 c = try_3way_compare(operand1, operand2);
883 if (type1 == &PyString_Type) {
884 Py_uintptr_t aa = (Py_uintptr_t)operand1;
885 Py_uintptr_t bb = (Py_uintptr_t)operand2;
887 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
888 }
else if (operand1 == Py_None) {
891 }
else if (operand2 == Py_None) {
894 }
else if (PyNumber_Check(operand1)) {
897 if (PyNumber_Check(operand2)) {
899 Py_uintptr_t aa = (Py_uintptr_t)type1;
900 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
902 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
906 }
else if (PyNumber_Check(operand2)) {
910 int s = strcmp(type1->tp_name,
"str");
918 Py_uintptr_t aa = (Py_uintptr_t)type1;
919 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
921 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
926 Py_LeaveRecursiveCall();
928 if (unlikely(c <= -2)) {
954 PyObject *result = BOOL_FROM(r);
955 Py_INCREF_IMMORTAL(result);
958 bool checked_reverse_op =
false;
961 if (type1 != &PyString_Type && Nuitka_Type_IsSubtype(&PyString_Type, type1)) {
962 f = PyString_Type.tp_richcompare;
965 checked_reverse_op =
true;
967 PyObject *result = (*f)(operand2, operand1, Py_GT);
969 if (result != Py_NotImplemented) {
970 Py_LeaveRecursiveCall();
975 Py_DECREF_IMMORTAL(result);
979 f = TP_RICHCOMPARE(type1);
982 PyObject *result = (*f)(operand1, operand2, Py_LT);
984 if (result != Py_NotImplemented) {
985 Py_LeaveRecursiveCall();
990 Py_DECREF_IMMORTAL(result);
993 if (checked_reverse_op ==
false) {
994 f = PyString_Type.tp_richcompare;
997 PyObject *result = (*f)(operand2, operand1, Py_GT);
999 if (result != Py_NotImplemented) {
1000 Py_LeaveRecursiveCall();
1005 Py_DECREF_IMMORTAL(result);
1009 Py_LeaveRecursiveCall();
1015 bool r = operand1 == operand2;
1016 PyObject *result = BOOL_FROM(r);
1017 Py_INCREF_IMMORTAL(result);
1021 bool r = operand1 != operand2;
1022 PyObject *result = BOOL_FROM(r);
1023 Py_INCREF_IMMORTAL(result);
1027#if PYTHON_VERSION < 0x360
1028 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < str()", type1->tp_name);
1030 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'str'", type1->tp_name);
1038#if PYTHON_VERSION < 0x300
1040PyObject *RICH_COMPARE_LT_OBJECT_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
1042 if (&PyString_Type == Py_TYPE(operand2)) {
1043 return COMPARE_LT_OBJECT_STR_STR(operand1, operand2);
1046#if PYTHON_VERSION < 0x300
1047 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1051 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1056 PyTypeObject *type2 = Py_TYPE(operand2);
1058#if PYTHON_VERSION < 0x300
1060 if (&PyString_Type == type2 && !0) {
1062 richcmpfunc frich = PyString_Type.tp_richcompare;
1064 if (frich != NULL) {
1065 PyObject *result = (*frich)(operand1, operand2, Py_LT);
1067 if (result != Py_NotImplemented) {
1068 Py_LeaveRecursiveCall();
1073 Py_DECREF_IMMORTAL(result);
1077 cmpfunc fcmp = NULL;
1080 int c = (*fcmp)(operand1, operand2);
1081 c = adjust_tp_compare(c);
1083 Py_LeaveRecursiveCall();
1109 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1113 PyObject *result = BOOL_FROM(r);
1114 Py_INCREF_IMMORTAL(result);
1122 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1123 f = TP_RICHCOMPARE(type2);
1126 PyObject *result = (*f)(operand2, operand1, Py_GT);
1128 if (result != Py_NotImplemented) {
1129 Py_LeaveRecursiveCall();
1134 Py_DECREF_IMMORTAL(result);
1138 f = PyString_Type.tp_richcompare;
1140 PyObject *result = (*f)(operand1, operand2, Py_LT);
1142 if (result != Py_NotImplemented) {
1143 Py_LeaveRecursiveCall();
1148 Py_DECREF_IMMORTAL(result);
1151 f = TP_RICHCOMPARE(type2);
1153 PyObject *result = (*f)(operand2, operand1, Py_GT);
1155 if (result != Py_NotImplemented) {
1156 Py_LeaveRecursiveCall();
1161 Py_DECREF_IMMORTAL(result);
1167 cmpfunc fcmp = NULL;
1168 c = (*fcmp)(operand1, operand2);
1169 }
else if (PyInstance_Check(operand2)) {
1170 cmpfunc fcmp = type2->tp_compare;
1171 c = (*fcmp)(operand1, operand2);
1173 c = try_3way_compare(operand1, operand2);
1177 if (&PyString_Type == type2) {
1178 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1179 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1181 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1182 }
else if (operand1 == Py_None) {
1185 }
else if (operand2 == Py_None) {
1188 }
else if (PyNumber_Check(operand1)) {
1191 if (PyNumber_Check(operand2)) {
1193 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1194 Py_uintptr_t bb = (Py_uintptr_t)type2;
1196 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1200 }
else if (PyNumber_Check(operand2)) {
1204 int s = strcmp(
"str", type2->tp_name);
1212 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1213 Py_uintptr_t bb = (Py_uintptr_t)type2;
1215 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1220 Py_LeaveRecursiveCall();
1222 if (unlikely(c <= -2)) {
1248 PyObject *result = BOOL_FROM(r);
1249 Py_INCREF_IMMORTAL(result);
1252 bool checked_reverse_op =
false;
1255 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1256 f = TP_RICHCOMPARE(type2);
1259 checked_reverse_op =
true;
1261 PyObject *result = (*f)(operand2, operand1, Py_GT);
1263 if (result != Py_NotImplemented) {
1264 Py_LeaveRecursiveCall();
1269 Py_DECREF_IMMORTAL(result);
1273 f = PyString_Type.tp_richcompare;
1276 PyObject *result = (*f)(operand1, operand2, Py_LT);
1278 if (result != Py_NotImplemented) {
1279 Py_LeaveRecursiveCall();
1284 Py_DECREF_IMMORTAL(result);
1287 if (checked_reverse_op ==
false) {
1288 f = TP_RICHCOMPARE(type2);
1291 PyObject *result = (*f)(operand2, operand1, Py_GT);
1293 if (result != Py_NotImplemented) {
1294 Py_LeaveRecursiveCall();
1299 Py_DECREF_IMMORTAL(result);
1303 Py_LeaveRecursiveCall();
1309 bool r = operand1 == operand2;
1310 PyObject *result = BOOL_FROM(r);
1311 Py_INCREF_IMMORTAL(result);
1315 bool r = operand1 != operand2;
1316 PyObject *result = BOOL_FROM(r);
1317 Py_INCREF_IMMORTAL(result);
1321#if PYTHON_VERSION < 0x360
1322 PyErr_Format(PyExc_TypeError,
"unorderable types: str() < %s()", type2->tp_name);
1324 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'str' and '%s'", type2->tp_name);
1332#if PYTHON_VERSION < 0x300
1334PyObject *RICH_COMPARE_LT_OBJECT_STR_STR(PyObject *operand1, PyObject *operand2) {
1336 return COMPARE_LT_OBJECT_STR_STR(operand1, operand2);
1340#if PYTHON_VERSION < 0x300
1341static bool COMPARE_LT_CBOOL_STR_STR(PyObject *operand1, PyObject *operand2) {
1342 CHECK_OBJECT(operand1);
1343 assert(PyString_CheckExact(operand1));
1344 CHECK_OBJECT(operand2);
1345 assert(PyString_CheckExact(operand2));
1347 PyStringObject *a = (PyStringObject *)operand1;
1348 PyStringObject *b = (PyStringObject *)operand2;
1351 if (operand1 == operand2) {
1360 Py_ssize_t len_a = Py_SIZE(operand1);
1361 Py_ssize_t len_b = Py_SIZE(operand2);
1363 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
1367 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
1370 c = memcmp(a->ob_sval, b->ob_sval, min_len);
1377 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
1383 bool result = c != 0;
1388#if PYTHON_VERSION < 0x300
1390bool RICH_COMPARE_LT_CBOOL_STR_STR(PyObject *operand1, PyObject *operand2) {
1392 return COMPARE_LT_CBOOL_STR_STR(operand1, operand2);
1396#if PYTHON_VERSION < 0x300
1398nuitka_bool RICH_COMPARE_LT_NBOOL_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
1400 if (Py_TYPE(operand1) == &PyString_Type) {
1401 return COMPARE_LT_CBOOL_STR_STR(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1404#if PYTHON_VERSION < 0x300
1405 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1406 return NUITKA_BOOL_EXCEPTION;
1409 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1410 return NUITKA_BOOL_EXCEPTION;
1414 PyTypeObject *type1 = Py_TYPE(operand1);
1416#if PYTHON_VERSION < 0x300
1418 if (type1 == &PyString_Type && !0) {
1420 richcmpfunc frich = PyString_Type.tp_richcompare;
1422 if (frich != NULL) {
1423 PyObject *result = (*frich)(operand1, operand2, Py_LT);
1425 if (result != Py_NotImplemented) {
1426 Py_LeaveRecursiveCall();
1428 if (unlikely(result == NULL)) {
1429 return NUITKA_BOOL_EXCEPTION;
1433 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1439 Py_DECREF_IMMORTAL(result);
1443 cmpfunc fcmp = NULL;
1446 int c = (*fcmp)(operand1, operand2);
1447 c = adjust_tp_compare(c);
1449 Py_LeaveRecursiveCall();
1452 return NUITKA_BOOL_EXCEPTION;
1475 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1479 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1488 if (type1 != &PyString_Type && 0) {
1489 f = PyString_Type.tp_richcompare;
1492 PyObject *result = (*f)(operand2, operand1, Py_GT);
1494 if (result != Py_NotImplemented) {
1495 Py_LeaveRecursiveCall();
1497 if (unlikely(result == NULL)) {
1498 return NUITKA_BOOL_EXCEPTION;
1502 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1508 Py_DECREF_IMMORTAL(result);
1512 f = TP_RICHCOMPARE(type1);
1514 PyObject *result = (*f)(operand1, operand2, Py_LT);
1516 if (result != Py_NotImplemented) {
1517 Py_LeaveRecursiveCall();
1519 if (unlikely(result == NULL)) {
1520 return NUITKA_BOOL_EXCEPTION;
1524 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1530 Py_DECREF_IMMORTAL(result);
1533 f = PyString_Type.tp_richcompare;
1535 PyObject *result = (*f)(operand2, operand1, Py_GT);
1537 if (result != Py_NotImplemented) {
1538 Py_LeaveRecursiveCall();
1540 if (unlikely(result == NULL)) {
1541 return NUITKA_BOOL_EXCEPTION;
1545 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1551 Py_DECREF_IMMORTAL(result);
1556 if (PyInstance_Check(operand1)) {
1557 cmpfunc fcmp = type1->tp_compare;
1558 c = (*fcmp)(operand1, operand2);
1560 cmpfunc fcmp = NULL;
1561 c = (*fcmp)(operand1, operand2);
1563 c = try_3way_compare(operand1, operand2);
1567 if (type1 == &PyString_Type) {
1568 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1569 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1571 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1572 }
else if (operand1 == Py_None) {
1575 }
else if (operand2 == Py_None) {
1578 }
else if (PyNumber_Check(operand1)) {
1581 if (PyNumber_Check(operand2)) {
1583 Py_uintptr_t aa = (Py_uintptr_t)type1;
1584 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
1586 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1590 }
else if (PyNumber_Check(operand2)) {
1594 int s = strcmp(type1->tp_name,
"str");
1602 Py_uintptr_t aa = (Py_uintptr_t)type1;
1603 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
1605 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1610 Py_LeaveRecursiveCall();
1612 if (unlikely(c <= -2)) {
1613 return NUITKA_BOOL_EXCEPTION;
1638 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1642 bool checked_reverse_op =
false;
1645 if (type1 != &PyString_Type && Nuitka_Type_IsSubtype(&PyString_Type, type1)) {
1646 f = PyString_Type.tp_richcompare;
1649 checked_reverse_op =
true;
1651 PyObject *result = (*f)(operand2, operand1, Py_GT);
1653 if (result != Py_NotImplemented) {
1654 Py_LeaveRecursiveCall();
1656 if (unlikely(result == NULL)) {
1657 return NUITKA_BOOL_EXCEPTION;
1661 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1667 Py_DECREF_IMMORTAL(result);
1671 f = TP_RICHCOMPARE(type1);
1674 PyObject *result = (*f)(operand1, operand2, Py_LT);
1676 if (result != Py_NotImplemented) {
1677 Py_LeaveRecursiveCall();
1679 if (unlikely(result == NULL)) {
1680 return NUITKA_BOOL_EXCEPTION;
1684 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1690 Py_DECREF_IMMORTAL(result);
1693 if (checked_reverse_op ==
false) {
1694 f = PyString_Type.tp_richcompare;
1697 PyObject *result = (*f)(operand2, operand1, Py_GT);
1699 if (result != Py_NotImplemented) {
1700 Py_LeaveRecursiveCall();
1702 if (unlikely(result == NULL)) {
1703 return NUITKA_BOOL_EXCEPTION;
1707 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1713 Py_DECREF_IMMORTAL(result);
1717 Py_LeaveRecursiveCall();
1723 bool r = operand1 == operand2;
1724 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1729 bool r = operand1 != operand2;
1730 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1735#if PYTHON_VERSION < 0x360
1736 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < str()", type1->tp_name);
1738 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'str'", type1->tp_name);
1740 return NUITKA_BOOL_EXCEPTION;
1746#if PYTHON_VERSION < 0x300
1748nuitka_bool RICH_COMPARE_LT_NBOOL_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
1750 if (&PyString_Type == Py_TYPE(operand2)) {
1751 return COMPARE_LT_CBOOL_STR_STR(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1754#if PYTHON_VERSION < 0x300
1755 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1756 return NUITKA_BOOL_EXCEPTION;
1759 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1760 return NUITKA_BOOL_EXCEPTION;
1764 PyTypeObject *type2 = Py_TYPE(operand2);
1766#if PYTHON_VERSION < 0x300
1768 if (&PyString_Type == type2 && !0) {
1770 richcmpfunc frich = PyString_Type.tp_richcompare;
1772 if (frich != NULL) {
1773 PyObject *result = (*frich)(operand1, operand2, Py_LT);
1775 if (result != Py_NotImplemented) {
1776 Py_LeaveRecursiveCall();
1778 if (unlikely(result == NULL)) {
1779 return NUITKA_BOOL_EXCEPTION;
1783 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1789 Py_DECREF_IMMORTAL(result);
1793 cmpfunc fcmp = NULL;
1796 int c = (*fcmp)(operand1, operand2);
1797 c = adjust_tp_compare(c);
1799 Py_LeaveRecursiveCall();
1802 return NUITKA_BOOL_EXCEPTION;
1825 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1829 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1838 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1839 f = TP_RICHCOMPARE(type2);
1842 PyObject *result = (*f)(operand2, operand1, Py_GT);
1844 if (result != Py_NotImplemented) {
1845 Py_LeaveRecursiveCall();
1847 if (unlikely(result == NULL)) {
1848 return NUITKA_BOOL_EXCEPTION;
1852 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1858 Py_DECREF_IMMORTAL(result);
1862 f = PyString_Type.tp_richcompare;
1864 PyObject *result = (*f)(operand1, operand2, Py_LT);
1866 if (result != Py_NotImplemented) {
1867 Py_LeaveRecursiveCall();
1869 if (unlikely(result == NULL)) {
1870 return NUITKA_BOOL_EXCEPTION;
1874 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1880 Py_DECREF_IMMORTAL(result);
1883 f = TP_RICHCOMPARE(type2);
1885 PyObject *result = (*f)(operand2, operand1, Py_GT);
1887 if (result != Py_NotImplemented) {
1888 Py_LeaveRecursiveCall();
1890 if (unlikely(result == NULL)) {
1891 return NUITKA_BOOL_EXCEPTION;
1895 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1901 Py_DECREF_IMMORTAL(result);
1907 cmpfunc fcmp = NULL;
1908 c = (*fcmp)(operand1, operand2);
1909 }
else if (PyInstance_Check(operand2)) {
1910 cmpfunc fcmp = type2->tp_compare;
1911 c = (*fcmp)(operand1, operand2);
1913 c = try_3way_compare(operand1, operand2);
1917 if (&PyString_Type == type2) {
1918 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1919 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1921 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1922 }
else if (operand1 == Py_None) {
1925 }
else if (operand2 == Py_None) {
1928 }
else if (PyNumber_Check(operand1)) {
1931 if (PyNumber_Check(operand2)) {
1933 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1934 Py_uintptr_t bb = (Py_uintptr_t)type2;
1936 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1940 }
else if (PyNumber_Check(operand2)) {
1944 int s = strcmp(
"str", type2->tp_name);
1952 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1953 Py_uintptr_t bb = (Py_uintptr_t)type2;
1955 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1960 Py_LeaveRecursiveCall();
1962 if (unlikely(c <= -2)) {
1963 return NUITKA_BOOL_EXCEPTION;
1988 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1992 bool checked_reverse_op =
false;
1995 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1996 f = TP_RICHCOMPARE(type2);
1999 checked_reverse_op =
true;
2001 PyObject *result = (*f)(operand2, operand1, Py_GT);
2003 if (result != Py_NotImplemented) {
2004 Py_LeaveRecursiveCall();
2006 if (unlikely(result == NULL)) {
2007 return NUITKA_BOOL_EXCEPTION;
2011 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2017 Py_DECREF_IMMORTAL(result);
2021 f = PyString_Type.tp_richcompare;
2024 PyObject *result = (*f)(operand1, operand2, Py_LT);
2026 if (result != Py_NotImplemented) {
2027 Py_LeaveRecursiveCall();
2029 if (unlikely(result == NULL)) {
2030 return NUITKA_BOOL_EXCEPTION;
2034 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2040 Py_DECREF_IMMORTAL(result);
2043 if (checked_reverse_op ==
false) {
2044 f = TP_RICHCOMPARE(type2);
2047 PyObject *result = (*f)(operand2, operand1, Py_GT);
2049 if (result != Py_NotImplemented) {
2050 Py_LeaveRecursiveCall();
2052 if (unlikely(result == NULL)) {
2053 return NUITKA_BOOL_EXCEPTION;
2057 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2063 Py_DECREF_IMMORTAL(result);
2067 Py_LeaveRecursiveCall();
2073 bool r = operand1 == operand2;
2074 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2079 bool r = operand1 != operand2;
2080 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2085#if PYTHON_VERSION < 0x360
2086 PyErr_Format(PyExc_TypeError,
"unorderable types: str() < %s()", type2->tp_name);
2088 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'str' and '%s'", type2->tp_name);
2090 return NUITKA_BOOL_EXCEPTION;
2096static PyObject *COMPARE_LT_OBJECT_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2097 CHECK_OBJECT(operand1);
2098 assert(PyUnicode_CheckExact(operand1));
2099 CHECK_OBJECT(operand2);
2100 assert(PyUnicode_CheckExact(operand2));
2102 PyUnicodeObject *a = (PyUnicodeObject *)operand1;
2103 PyUnicodeObject *b = (PyUnicodeObject *)operand2;
2106 if (operand1 == operand2) {
2110 PyObject *result = BOOL_FROM(r);
2111 Py_INCREF_IMMORTAL(result);
2115 PyObject *r = PyUnicode_RichCompare((PyObject *)a, (PyObject *)b, Py_LT);
2121PyObject *RICH_COMPARE_LT_OBJECT_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
2123 if (Py_TYPE(operand1) == &PyUnicode_Type) {
2124 return COMPARE_LT_OBJECT_UNICODE_UNICODE(operand1, operand2);
2127#if PYTHON_VERSION < 0x300
2128 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2132 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2137 PyTypeObject *type1 = Py_TYPE(operand1);
2139#if PYTHON_VERSION < 0x300
2141 if (type1 == &PyUnicode_Type && !0) {
2143 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2145 if (frich != NULL) {
2146 PyObject *result = (*frich)(operand1, operand2, Py_LT);
2148 if (result != Py_NotImplemented) {
2149 Py_LeaveRecursiveCall();
2154 Py_DECREF_IMMORTAL(result);
2158 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2161 int c = (*fcmp)(operand1, operand2);
2162 c = adjust_tp_compare(c);
2164 Py_LeaveRecursiveCall();
2190 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2194 PyObject *result = BOOL_FROM(r);
2195 Py_INCREF_IMMORTAL(result);
2203 if (type1 != &PyUnicode_Type && 0) {
2204 f = PyUnicode_Type.tp_richcompare;
2207 PyObject *result = (*f)(operand2, operand1, Py_GT);
2209 if (result != Py_NotImplemented) {
2210 Py_LeaveRecursiveCall();
2215 Py_DECREF_IMMORTAL(result);
2219 f = TP_RICHCOMPARE(type1);
2221 PyObject *result = (*f)(operand1, operand2, Py_LT);
2223 if (result != Py_NotImplemented) {
2224 Py_LeaveRecursiveCall();
2229 Py_DECREF_IMMORTAL(result);
2232 f = PyUnicode_Type.tp_richcompare;
2234 PyObject *result = (*f)(operand2, operand1, Py_GT);
2236 if (result != Py_NotImplemented) {
2237 Py_LeaveRecursiveCall();
2242 Py_DECREF_IMMORTAL(result);
2247 if (PyInstance_Check(operand1)) {
2248 cmpfunc fcmp = type1->tp_compare;
2249 c = (*fcmp)(operand1, operand2);
2251 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2252 c = (*fcmp)(operand1, operand2);
2254 c = try_3way_compare(operand1, operand2);
2258 if (type1 == &PyUnicode_Type) {
2259 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2260 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2262 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2263 }
else if (operand1 == Py_None) {
2266 }
else if (operand2 == Py_None) {
2269 }
else if (PyNumber_Check(operand1)) {
2272 if (PyNumber_Check(operand2)) {
2274 Py_uintptr_t aa = (Py_uintptr_t)type1;
2275 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2277 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2281 }
else if (PyNumber_Check(operand2)) {
2285 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"unicode" :
"str"));
2293 Py_uintptr_t aa = (Py_uintptr_t)type1;
2294 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2296 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2301 Py_LeaveRecursiveCall();
2303 if (unlikely(c <= -2)) {
2329 PyObject *result = BOOL_FROM(r);
2330 Py_INCREF_IMMORTAL(result);
2333 bool checked_reverse_op =
false;
2336 if (type1 != &PyUnicode_Type && Nuitka_Type_IsSubtype(&PyUnicode_Type, type1)) {
2337 f = PyUnicode_Type.tp_richcompare;
2340 checked_reverse_op =
true;
2342 PyObject *result = (*f)(operand2, operand1, Py_GT);
2344 if (result != Py_NotImplemented) {
2345 Py_LeaveRecursiveCall();
2350 Py_DECREF_IMMORTAL(result);
2354 f = TP_RICHCOMPARE(type1);
2357 PyObject *result = (*f)(operand1, operand2, Py_LT);
2359 if (result != Py_NotImplemented) {
2360 Py_LeaveRecursiveCall();
2365 Py_DECREF_IMMORTAL(result);
2368 if (checked_reverse_op ==
false) {
2369 f = PyUnicode_Type.tp_richcompare;
2372 PyObject *result = (*f)(operand2, operand1, Py_GT);
2374 if (result != Py_NotImplemented) {
2375 Py_LeaveRecursiveCall();
2380 Py_DECREF_IMMORTAL(result);
2384 Py_LeaveRecursiveCall();
2390 bool r = operand1 == operand2;
2391 PyObject *result = BOOL_FROM(r);
2392 Py_INCREF_IMMORTAL(result);
2396 bool r = operand1 != operand2;
2397 PyObject *result = BOOL_FROM(r);
2398 Py_INCREF_IMMORTAL(result);
2402#if PYTHON_VERSION < 0x300
2403 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < unicode()", type1->tp_name);
2404#elif PYTHON_VERSION < 0x360
2405 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < str()", type1->tp_name);
2407 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'str'", type1->tp_name);
2415PyObject *RICH_COMPARE_LT_OBJECT_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
2417 if (&PyUnicode_Type == Py_TYPE(operand2)) {
2418 return COMPARE_LT_OBJECT_UNICODE_UNICODE(operand1, operand2);
2421#if PYTHON_VERSION < 0x300
2422 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2426 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2431 PyTypeObject *type2 = Py_TYPE(operand2);
2433#if PYTHON_VERSION < 0x300
2435 if (&PyUnicode_Type == type2 && !0) {
2437 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2439 if (frich != NULL) {
2440 PyObject *result = (*frich)(operand1, operand2, Py_LT);
2442 if (result != Py_NotImplemented) {
2443 Py_LeaveRecursiveCall();
2448 Py_DECREF_IMMORTAL(result);
2452 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2455 int c = (*fcmp)(operand1, operand2);
2456 c = adjust_tp_compare(c);
2458 Py_LeaveRecursiveCall();
2484 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2488 PyObject *result = BOOL_FROM(r);
2489 Py_INCREF_IMMORTAL(result);
2497 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
2498 f = TP_RICHCOMPARE(type2);
2501 PyObject *result = (*f)(operand2, operand1, Py_GT);
2503 if (result != Py_NotImplemented) {
2504 Py_LeaveRecursiveCall();
2509 Py_DECREF_IMMORTAL(result);
2513 f = PyUnicode_Type.tp_richcompare;
2515 PyObject *result = (*f)(operand1, operand2, Py_LT);
2517 if (result != Py_NotImplemented) {
2518 Py_LeaveRecursiveCall();
2523 Py_DECREF_IMMORTAL(result);
2526 f = TP_RICHCOMPARE(type2);
2528 PyObject *result = (*f)(operand2, operand1, Py_GT);
2530 if (result != Py_NotImplemented) {
2531 Py_LeaveRecursiveCall();
2536 Py_DECREF_IMMORTAL(result);
2542 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2543 c = (*fcmp)(operand1, operand2);
2544 }
else if (PyInstance_Check(operand2)) {
2545 cmpfunc fcmp = type2->tp_compare;
2546 c = (*fcmp)(operand1, operand2);
2548 c = try_3way_compare(operand1, operand2);
2552 if (&PyUnicode_Type == type2) {
2553 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2554 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2556 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2557 }
else if (operand1 == Py_None) {
2560 }
else if (operand2 == Py_None) {
2563 }
else if (PyNumber_Check(operand1)) {
2566 if (PyNumber_Check(operand2)) {
2568 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
2569 Py_uintptr_t bb = (Py_uintptr_t)type2;
2571 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2575 }
else if (PyNumber_Check(operand2)) {
2579 int s = strcmp((PYTHON_VERSION < 0x300 ?
"unicode" :
"str"), type2->tp_name);
2587 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
2588 Py_uintptr_t bb = (Py_uintptr_t)type2;
2590 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2595 Py_LeaveRecursiveCall();
2597 if (unlikely(c <= -2)) {
2623 PyObject *result = BOOL_FROM(r);
2624 Py_INCREF_IMMORTAL(result);
2627 bool checked_reverse_op =
false;
2630 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
2631 f = TP_RICHCOMPARE(type2);
2634 checked_reverse_op =
true;
2636 PyObject *result = (*f)(operand2, operand1, Py_GT);
2638 if (result != Py_NotImplemented) {
2639 Py_LeaveRecursiveCall();
2644 Py_DECREF_IMMORTAL(result);
2648 f = PyUnicode_Type.tp_richcompare;
2651 PyObject *result = (*f)(operand1, operand2, Py_LT);
2653 if (result != Py_NotImplemented) {
2654 Py_LeaveRecursiveCall();
2659 Py_DECREF_IMMORTAL(result);
2662 if (checked_reverse_op ==
false) {
2663 f = TP_RICHCOMPARE(type2);
2666 PyObject *result = (*f)(operand2, operand1, Py_GT);
2668 if (result != Py_NotImplemented) {
2669 Py_LeaveRecursiveCall();
2674 Py_DECREF_IMMORTAL(result);
2678 Py_LeaveRecursiveCall();
2684 bool r = operand1 == operand2;
2685 PyObject *result = BOOL_FROM(r);
2686 Py_INCREF_IMMORTAL(result);
2690 bool r = operand1 != operand2;
2691 PyObject *result = BOOL_FROM(r);
2692 Py_INCREF_IMMORTAL(result);
2696#if PYTHON_VERSION < 0x300
2697 PyErr_Format(PyExc_TypeError,
"unorderable types: unicode() < %s()", type2->tp_name);
2698#elif PYTHON_VERSION < 0x360
2699 PyErr_Format(PyExc_TypeError,
"unorderable types: str() < %s()", type2->tp_name);
2701 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'str' and '%s'", type2->tp_name);
2710PyObject *RICH_COMPARE_LT_OBJECT_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2712 return COMPARE_LT_OBJECT_UNICODE_UNICODE(operand1, operand2);
2715static bool COMPARE_LT_CBOOL_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2716 CHECK_OBJECT(operand1);
2717 assert(PyUnicode_CheckExact(operand1));
2718 CHECK_OBJECT(operand2);
2719 assert(PyUnicode_CheckExact(operand2));
2721 PyUnicodeObject *a = (PyUnicodeObject *)operand1;
2722 PyUnicodeObject *b = (PyUnicodeObject *)operand2;
2725 if (operand1 == operand2) {
2734 PyObject *r = PyUnicode_RichCompare((PyObject *)a, (PyObject *)b, Py_LT);
2738 bool result = r == Py_True;
2739 Py_DECREF_IMMORTAL(r);
2745bool RICH_COMPARE_LT_CBOOL_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2747 return COMPARE_LT_CBOOL_UNICODE_UNICODE(operand1, operand2);
2751nuitka_bool RICH_COMPARE_LT_NBOOL_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
2753 if (Py_TYPE(operand1) == &PyUnicode_Type) {
2754 return COMPARE_LT_CBOOL_UNICODE_UNICODE(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2757#if PYTHON_VERSION < 0x300
2758 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2759 return NUITKA_BOOL_EXCEPTION;
2762 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2763 return NUITKA_BOOL_EXCEPTION;
2767 PyTypeObject *type1 = Py_TYPE(operand1);
2769#if PYTHON_VERSION < 0x300
2771 if (type1 == &PyUnicode_Type && !0) {
2773 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2775 if (frich != NULL) {
2776 PyObject *result = (*frich)(operand1, operand2, Py_LT);
2778 if (result != Py_NotImplemented) {
2779 Py_LeaveRecursiveCall();
2781 if (unlikely(result == NULL)) {
2782 return NUITKA_BOOL_EXCEPTION;
2786 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2792 Py_DECREF_IMMORTAL(result);
2796 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2799 int c = (*fcmp)(operand1, operand2);
2800 c = adjust_tp_compare(c);
2802 Py_LeaveRecursiveCall();
2805 return NUITKA_BOOL_EXCEPTION;
2828 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2832 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2841 if (type1 != &PyUnicode_Type && 0) {
2842 f = PyUnicode_Type.tp_richcompare;
2845 PyObject *result = (*f)(operand2, operand1, Py_GT);
2847 if (result != Py_NotImplemented) {
2848 Py_LeaveRecursiveCall();
2850 if (unlikely(result == NULL)) {
2851 return NUITKA_BOOL_EXCEPTION;
2855 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2861 Py_DECREF_IMMORTAL(result);
2865 f = TP_RICHCOMPARE(type1);
2867 PyObject *result = (*f)(operand1, operand2, Py_LT);
2869 if (result != Py_NotImplemented) {
2870 Py_LeaveRecursiveCall();
2872 if (unlikely(result == NULL)) {
2873 return NUITKA_BOOL_EXCEPTION;
2877 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2883 Py_DECREF_IMMORTAL(result);
2886 f = PyUnicode_Type.tp_richcompare;
2888 PyObject *result = (*f)(operand2, operand1, Py_GT);
2890 if (result != Py_NotImplemented) {
2891 Py_LeaveRecursiveCall();
2893 if (unlikely(result == NULL)) {
2894 return NUITKA_BOOL_EXCEPTION;
2898 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2904 Py_DECREF_IMMORTAL(result);
2909 if (PyInstance_Check(operand1)) {
2910 cmpfunc fcmp = type1->tp_compare;
2911 c = (*fcmp)(operand1, operand2);
2913 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2914 c = (*fcmp)(operand1, operand2);
2916 c = try_3way_compare(operand1, operand2);
2920 if (type1 == &PyUnicode_Type) {
2921 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2922 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2924 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2925 }
else if (operand1 == Py_None) {
2928 }
else if (operand2 == Py_None) {
2931 }
else if (PyNumber_Check(operand1)) {
2934 if (PyNumber_Check(operand2)) {
2936 Py_uintptr_t aa = (Py_uintptr_t)type1;
2937 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2939 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2943 }
else if (PyNumber_Check(operand2)) {
2947 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"unicode" :
"str"));
2955 Py_uintptr_t aa = (Py_uintptr_t)type1;
2956 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2958 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2963 Py_LeaveRecursiveCall();
2965 if (unlikely(c <= -2)) {
2966 return NUITKA_BOOL_EXCEPTION;
2991 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2995 bool checked_reverse_op =
false;
2998 if (type1 != &PyUnicode_Type && Nuitka_Type_IsSubtype(&PyUnicode_Type, type1)) {
2999 f = PyUnicode_Type.tp_richcompare;
3002 checked_reverse_op =
true;
3004 PyObject *result = (*f)(operand2, operand1, Py_GT);
3006 if (result != Py_NotImplemented) {
3007 Py_LeaveRecursiveCall();
3009 if (unlikely(result == NULL)) {
3010 return NUITKA_BOOL_EXCEPTION;
3014 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3020 Py_DECREF_IMMORTAL(result);
3024 f = TP_RICHCOMPARE(type1);
3027 PyObject *result = (*f)(operand1, operand2, Py_LT);
3029 if (result != Py_NotImplemented) {
3030 Py_LeaveRecursiveCall();
3032 if (unlikely(result == NULL)) {
3033 return NUITKA_BOOL_EXCEPTION;
3037 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3043 Py_DECREF_IMMORTAL(result);
3046 if (checked_reverse_op ==
false) {
3047 f = PyUnicode_Type.tp_richcompare;
3050 PyObject *result = (*f)(operand2, operand1, Py_GT);
3052 if (result != Py_NotImplemented) {
3053 Py_LeaveRecursiveCall();
3055 if (unlikely(result == NULL)) {
3056 return NUITKA_BOOL_EXCEPTION;
3060 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3066 Py_DECREF_IMMORTAL(result);
3070 Py_LeaveRecursiveCall();
3076 bool r = operand1 == operand2;
3077 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3082 bool r = operand1 != operand2;
3083 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3088#if PYTHON_VERSION < 0x300
3089 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < unicode()", type1->tp_name);
3090#elif PYTHON_VERSION < 0x360
3091 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < str()", type1->tp_name);
3093 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'str'", type1->tp_name);
3095 return NUITKA_BOOL_EXCEPTION;
3101nuitka_bool RICH_COMPARE_LT_NBOOL_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
3103 if (&PyUnicode_Type == Py_TYPE(operand2)) {
3104 return COMPARE_LT_CBOOL_UNICODE_UNICODE(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3107#if PYTHON_VERSION < 0x300
3108 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3109 return NUITKA_BOOL_EXCEPTION;
3112 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3113 return NUITKA_BOOL_EXCEPTION;
3117 PyTypeObject *type2 = Py_TYPE(operand2);
3119#if PYTHON_VERSION < 0x300
3121 if (&PyUnicode_Type == type2 && !0) {
3123 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
3125 if (frich != NULL) {
3126 PyObject *result = (*frich)(operand1, operand2, Py_LT);
3128 if (result != Py_NotImplemented) {
3129 Py_LeaveRecursiveCall();
3131 if (unlikely(result == NULL)) {
3132 return NUITKA_BOOL_EXCEPTION;
3136 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3142 Py_DECREF_IMMORTAL(result);
3146 cmpfunc fcmp = PyUnicode_Type.tp_compare;
3149 int c = (*fcmp)(operand1, operand2);
3150 c = adjust_tp_compare(c);
3152 Py_LeaveRecursiveCall();
3155 return NUITKA_BOOL_EXCEPTION;
3178 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3182 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3191 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
3192 f = TP_RICHCOMPARE(type2);
3195 PyObject *result = (*f)(operand2, operand1, Py_GT);
3197 if (result != Py_NotImplemented) {
3198 Py_LeaveRecursiveCall();
3200 if (unlikely(result == NULL)) {
3201 return NUITKA_BOOL_EXCEPTION;
3205 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3211 Py_DECREF_IMMORTAL(result);
3215 f = PyUnicode_Type.tp_richcompare;
3217 PyObject *result = (*f)(operand1, operand2, Py_LT);
3219 if (result != Py_NotImplemented) {
3220 Py_LeaveRecursiveCall();
3222 if (unlikely(result == NULL)) {
3223 return NUITKA_BOOL_EXCEPTION;
3227 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3233 Py_DECREF_IMMORTAL(result);
3236 f = TP_RICHCOMPARE(type2);
3238 PyObject *result = (*f)(operand2, operand1, Py_GT);
3240 if (result != Py_NotImplemented) {
3241 Py_LeaveRecursiveCall();
3243 if (unlikely(result == NULL)) {
3244 return NUITKA_BOOL_EXCEPTION;
3248 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3254 Py_DECREF_IMMORTAL(result);
3260 cmpfunc fcmp = PyUnicode_Type.tp_compare;
3261 c = (*fcmp)(operand1, operand2);
3262 }
else if (PyInstance_Check(operand2)) {
3263 cmpfunc fcmp = type2->tp_compare;
3264 c = (*fcmp)(operand1, operand2);
3266 c = try_3way_compare(operand1, operand2);
3270 if (&PyUnicode_Type == type2) {
3271 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3272 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3274 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3275 }
else if (operand1 == Py_None) {
3278 }
else if (operand2 == Py_None) {
3281 }
else if (PyNumber_Check(operand1)) {
3284 if (PyNumber_Check(operand2)) {
3286 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
3287 Py_uintptr_t bb = (Py_uintptr_t)type2;
3289 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3293 }
else if (PyNumber_Check(operand2)) {
3297 int s = strcmp((PYTHON_VERSION < 0x300 ?
"unicode" :
"str"), type2->tp_name);
3305 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
3306 Py_uintptr_t bb = (Py_uintptr_t)type2;
3308 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3313 Py_LeaveRecursiveCall();
3315 if (unlikely(c <= -2)) {
3316 return NUITKA_BOOL_EXCEPTION;
3341 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3345 bool checked_reverse_op =
false;
3348 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
3349 f = TP_RICHCOMPARE(type2);
3352 checked_reverse_op =
true;
3354 PyObject *result = (*f)(operand2, operand1, Py_GT);
3356 if (result != Py_NotImplemented) {
3357 Py_LeaveRecursiveCall();
3359 if (unlikely(result == NULL)) {
3360 return NUITKA_BOOL_EXCEPTION;
3364 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3370 Py_DECREF_IMMORTAL(result);
3374 f = PyUnicode_Type.tp_richcompare;
3377 PyObject *result = (*f)(operand1, operand2, Py_LT);
3379 if (result != Py_NotImplemented) {
3380 Py_LeaveRecursiveCall();
3382 if (unlikely(result == NULL)) {
3383 return NUITKA_BOOL_EXCEPTION;
3387 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3393 Py_DECREF_IMMORTAL(result);
3396 if (checked_reverse_op ==
false) {
3397 f = TP_RICHCOMPARE(type2);
3400 PyObject *result = (*f)(operand2, operand1, Py_GT);
3402 if (result != Py_NotImplemented) {
3403 Py_LeaveRecursiveCall();
3405 if (unlikely(result == NULL)) {
3406 return NUITKA_BOOL_EXCEPTION;
3410 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3416 Py_DECREF_IMMORTAL(result);
3420 Py_LeaveRecursiveCall();
3426 bool r = operand1 == operand2;
3427 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3432 bool r = operand1 != operand2;
3433 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3438#if PYTHON_VERSION < 0x300
3439 PyErr_Format(PyExc_TypeError,
"unorderable types: unicode() < %s()", type2->tp_name);
3440#elif PYTHON_VERSION < 0x360
3441 PyErr_Format(PyExc_TypeError,
"unorderable types: str() < %s()", type2->tp_name);
3443 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'str' and '%s'", type2->tp_name);
3445 return NUITKA_BOOL_EXCEPTION;
3450#if PYTHON_VERSION >= 0x300
3451static PyObject *COMPARE_LT_OBJECT_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
3452 CHECK_OBJECT(operand1);
3453 assert(PyBytes_CheckExact(operand1));
3454 CHECK_OBJECT(operand2);
3455 assert(PyBytes_CheckExact(operand2));
3457 PyBytesObject *a = (PyBytesObject *)operand1;
3458 PyBytesObject *b = (PyBytesObject *)operand2;
3461 if (operand1 == operand2) {
3465 PyObject *result = BOOL_FROM(r);
3466 Py_INCREF_IMMORTAL(result);
3470 Py_ssize_t len_a = Py_SIZE(operand1);
3471 Py_ssize_t len_b = Py_SIZE(operand2);
3473 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
3477 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
3480 c = memcmp(a->ob_sval, b->ob_sval, min_len);
3487 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
3493 PyObject *result = BOOL_FROM(c != 0);
3494 Py_INCREF_IMMORTAL(result);
3498#if PYTHON_VERSION >= 0x300
3500PyObject *RICH_COMPARE_LT_OBJECT_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
3502 if (Py_TYPE(operand1) == &PyBytes_Type) {
3503 return COMPARE_LT_OBJECT_BYTES_BYTES(operand1, operand2);
3506#if PYTHON_VERSION < 0x300
3507 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3511 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3516 PyTypeObject *type1 = Py_TYPE(operand1);
3518#if PYTHON_VERSION < 0x300
3520 if (type1 == &PyBytes_Type && !0) {
3522 richcmpfunc frich = PyBytes_Type.tp_richcompare;
3524 if (frich != NULL) {
3525 PyObject *result = (*frich)(operand1, operand2, Py_LT);
3527 if (result != Py_NotImplemented) {
3528 Py_LeaveRecursiveCall();
3533 Py_DECREF_IMMORTAL(result);
3537 cmpfunc fcmp = NULL;
3540 int c = (*fcmp)(operand1, operand2);
3541 c = adjust_tp_compare(c);
3543 Py_LeaveRecursiveCall();
3569 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3573 PyObject *result = BOOL_FROM(r);
3574 Py_INCREF_IMMORTAL(result);
3582 if (type1 != &PyBytes_Type && 0) {
3583 f = PyBytes_Type.tp_richcompare;
3586 PyObject *result = (*f)(operand2, operand1, Py_GT);
3588 if (result != Py_NotImplemented) {
3589 Py_LeaveRecursiveCall();
3594 Py_DECREF_IMMORTAL(result);
3598 f = TP_RICHCOMPARE(type1);
3600 PyObject *result = (*f)(operand1, operand2, Py_LT);
3602 if (result != Py_NotImplemented) {
3603 Py_LeaveRecursiveCall();
3608 Py_DECREF_IMMORTAL(result);
3611 f = PyBytes_Type.tp_richcompare;
3613 PyObject *result = (*f)(operand2, operand1, Py_GT);
3615 if (result != Py_NotImplemented) {
3616 Py_LeaveRecursiveCall();
3621 Py_DECREF_IMMORTAL(result);
3626 if (PyInstance_Check(operand1)) {
3627 cmpfunc fcmp = type1->tp_compare;
3628 c = (*fcmp)(operand1, operand2);
3630 cmpfunc fcmp = NULL;
3631 c = (*fcmp)(operand1, operand2);
3633 c = try_3way_compare(operand1, operand2);
3637 if (type1 == &PyBytes_Type) {
3638 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3639 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3641 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3642 }
else if (operand1 == Py_None) {
3645 }
else if (operand2 == Py_None) {
3648 }
else if (PyNumber_Check(operand1)) {
3651 if (PyNumber_Check(operand2)) {
3653 Py_uintptr_t aa = (Py_uintptr_t)type1;
3654 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
3656 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3660 }
else if (PyNumber_Check(operand2)) {
3664 int s = strcmp(type1->tp_name,
"bytes");
3672 Py_uintptr_t aa = (Py_uintptr_t)type1;
3673 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
3675 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3680 Py_LeaveRecursiveCall();
3682 if (unlikely(c <= -2)) {
3708 PyObject *result = BOOL_FROM(r);
3709 Py_INCREF_IMMORTAL(result);
3712 bool checked_reverse_op =
false;
3715 if (type1 != &PyBytes_Type && Nuitka_Type_IsSubtype(&PyBytes_Type, type1)) {
3716 f = PyBytes_Type.tp_richcompare;
3719 checked_reverse_op =
true;
3721 PyObject *result = (*f)(operand2, operand1, Py_GT);
3723 if (result != Py_NotImplemented) {
3724 Py_LeaveRecursiveCall();
3729 Py_DECREF_IMMORTAL(result);
3733 f = TP_RICHCOMPARE(type1);
3736 PyObject *result = (*f)(operand1, operand2, Py_LT);
3738 if (result != Py_NotImplemented) {
3739 Py_LeaveRecursiveCall();
3744 Py_DECREF_IMMORTAL(result);
3747 if (checked_reverse_op ==
false) {
3748 f = PyBytes_Type.tp_richcompare;
3751 PyObject *result = (*f)(operand2, operand1, Py_GT);
3753 if (result != Py_NotImplemented) {
3754 Py_LeaveRecursiveCall();
3759 Py_DECREF_IMMORTAL(result);
3763 Py_LeaveRecursiveCall();
3769 bool r = operand1 == operand2;
3770 PyObject *result = BOOL_FROM(r);
3771 Py_INCREF_IMMORTAL(result);
3775 bool r = operand1 != operand2;
3776 PyObject *result = BOOL_FROM(r);
3777 Py_INCREF_IMMORTAL(result);
3781#if PYTHON_VERSION < 0x360
3782 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < bytes()", type1->tp_name);
3784 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'bytes'", type1->tp_name);
3792#if PYTHON_VERSION >= 0x300
3794PyObject *RICH_COMPARE_LT_OBJECT_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
3796 if (&PyBytes_Type == Py_TYPE(operand2)) {
3797 return COMPARE_LT_OBJECT_BYTES_BYTES(operand1, operand2);
3800#if PYTHON_VERSION < 0x300
3801 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3805 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3810 PyTypeObject *type2 = Py_TYPE(operand2);
3812#if PYTHON_VERSION < 0x300
3814 if (&PyBytes_Type == type2 && !0) {
3816 richcmpfunc frich = PyBytes_Type.tp_richcompare;
3818 if (frich != NULL) {
3819 PyObject *result = (*frich)(operand1, operand2, Py_LT);
3821 if (result != Py_NotImplemented) {
3822 Py_LeaveRecursiveCall();
3827 Py_DECREF_IMMORTAL(result);
3831 cmpfunc fcmp = NULL;
3834 int c = (*fcmp)(operand1, operand2);
3835 c = adjust_tp_compare(c);
3837 Py_LeaveRecursiveCall();
3863 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3867 PyObject *result = BOOL_FROM(r);
3868 Py_INCREF_IMMORTAL(result);
3876 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
3877 f = TP_RICHCOMPARE(type2);
3880 PyObject *result = (*f)(operand2, operand1, Py_GT);
3882 if (result != Py_NotImplemented) {
3883 Py_LeaveRecursiveCall();
3888 Py_DECREF_IMMORTAL(result);
3892 f = PyBytes_Type.tp_richcompare;
3894 PyObject *result = (*f)(operand1, operand2, Py_LT);
3896 if (result != Py_NotImplemented) {
3897 Py_LeaveRecursiveCall();
3902 Py_DECREF_IMMORTAL(result);
3905 f = TP_RICHCOMPARE(type2);
3907 PyObject *result = (*f)(operand2, operand1, Py_GT);
3909 if (result != Py_NotImplemented) {
3910 Py_LeaveRecursiveCall();
3915 Py_DECREF_IMMORTAL(result);
3921 cmpfunc fcmp = NULL;
3922 c = (*fcmp)(operand1, operand2);
3923 }
else if (PyInstance_Check(operand2)) {
3924 cmpfunc fcmp = type2->tp_compare;
3925 c = (*fcmp)(operand1, operand2);
3927 c = try_3way_compare(operand1, operand2);
3931 if (&PyBytes_Type == type2) {
3932 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3933 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3935 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3936 }
else if (operand1 == Py_None) {
3939 }
else if (operand2 == Py_None) {
3942 }
else if (PyNumber_Check(operand1)) {
3945 if (PyNumber_Check(operand2)) {
3947 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
3948 Py_uintptr_t bb = (Py_uintptr_t)type2;
3950 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3954 }
else if (PyNumber_Check(operand2)) {
3958 int s = strcmp(
"bytes", type2->tp_name);
3966 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
3967 Py_uintptr_t bb = (Py_uintptr_t)type2;
3969 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3974 Py_LeaveRecursiveCall();
3976 if (unlikely(c <= -2)) {
4002 PyObject *result = BOOL_FROM(r);
4003 Py_INCREF_IMMORTAL(result);
4006 bool checked_reverse_op =
false;
4009 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4010 f = TP_RICHCOMPARE(type2);
4013 checked_reverse_op =
true;
4015 PyObject *result = (*f)(operand2, operand1, Py_GT);
4017 if (result != Py_NotImplemented) {
4018 Py_LeaveRecursiveCall();
4023 Py_DECREF_IMMORTAL(result);
4027 f = PyBytes_Type.tp_richcompare;
4030 PyObject *result = (*f)(operand1, operand2, Py_LT);
4032 if (result != Py_NotImplemented) {
4033 Py_LeaveRecursiveCall();
4038 Py_DECREF_IMMORTAL(result);
4041 if (checked_reverse_op ==
false) {
4042 f = TP_RICHCOMPARE(type2);
4045 PyObject *result = (*f)(operand2, operand1, Py_GT);
4047 if (result != Py_NotImplemented) {
4048 Py_LeaveRecursiveCall();
4053 Py_DECREF_IMMORTAL(result);
4057 Py_LeaveRecursiveCall();
4063 bool r = operand1 == operand2;
4064 PyObject *result = BOOL_FROM(r);
4065 Py_INCREF_IMMORTAL(result);
4069 bool r = operand1 != operand2;
4070 PyObject *result = BOOL_FROM(r);
4071 Py_INCREF_IMMORTAL(result);
4075#if PYTHON_VERSION < 0x360
4076 PyErr_Format(PyExc_TypeError,
"unorderable types: bytes() < %s()", type2->tp_name);
4078 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'bytes' and '%s'", type2->tp_name);
4086#if PYTHON_VERSION >= 0x300
4088PyObject *RICH_COMPARE_LT_OBJECT_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4090 return COMPARE_LT_OBJECT_BYTES_BYTES(operand1, operand2);
4094#if PYTHON_VERSION >= 0x300
4095static bool COMPARE_LT_CBOOL_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4096 CHECK_OBJECT(operand1);
4097 assert(PyBytes_CheckExact(operand1));
4098 CHECK_OBJECT(operand2);
4099 assert(PyBytes_CheckExact(operand2));
4101 PyBytesObject *a = (PyBytesObject *)operand1;
4102 PyBytesObject *b = (PyBytesObject *)operand2;
4105 if (operand1 == operand2) {
4114 Py_ssize_t len_a = Py_SIZE(operand1);
4115 Py_ssize_t len_b = Py_SIZE(operand2);
4117 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
4121 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
4124 c = memcmp(a->ob_sval, b->ob_sval, min_len);
4131 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
4137 bool result = c != 0;
4142#if PYTHON_VERSION >= 0x300
4144bool RICH_COMPARE_LT_CBOOL_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4146 return COMPARE_LT_CBOOL_BYTES_BYTES(operand1, operand2);
4150#if PYTHON_VERSION >= 0x300
4152nuitka_bool RICH_COMPARE_LT_NBOOL_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
4154 if (Py_TYPE(operand1) == &PyBytes_Type) {
4155 return COMPARE_LT_CBOOL_BYTES_BYTES(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4158#if PYTHON_VERSION < 0x300
4159 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4160 return NUITKA_BOOL_EXCEPTION;
4163 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4164 return NUITKA_BOOL_EXCEPTION;
4168 PyTypeObject *type1 = Py_TYPE(operand1);
4170#if PYTHON_VERSION < 0x300
4172 if (type1 == &PyBytes_Type && !0) {
4174 richcmpfunc frich = PyBytes_Type.tp_richcompare;
4176 if (frich != NULL) {
4177 PyObject *result = (*frich)(operand1, operand2, Py_LT);
4179 if (result != Py_NotImplemented) {
4180 Py_LeaveRecursiveCall();
4182 if (unlikely(result == NULL)) {
4183 return NUITKA_BOOL_EXCEPTION;
4187 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4193 Py_DECREF_IMMORTAL(result);
4197 cmpfunc fcmp = NULL;
4200 int c = (*fcmp)(operand1, operand2);
4201 c = adjust_tp_compare(c);
4203 Py_LeaveRecursiveCall();
4206 return NUITKA_BOOL_EXCEPTION;
4229 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4233 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4242 if (type1 != &PyBytes_Type && 0) {
4243 f = PyBytes_Type.tp_richcompare;
4246 PyObject *result = (*f)(operand2, operand1, Py_GT);
4248 if (result != Py_NotImplemented) {
4249 Py_LeaveRecursiveCall();
4251 if (unlikely(result == NULL)) {
4252 return NUITKA_BOOL_EXCEPTION;
4256 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4262 Py_DECREF_IMMORTAL(result);
4266 f = TP_RICHCOMPARE(type1);
4268 PyObject *result = (*f)(operand1, operand2, Py_LT);
4270 if (result != Py_NotImplemented) {
4271 Py_LeaveRecursiveCall();
4273 if (unlikely(result == NULL)) {
4274 return NUITKA_BOOL_EXCEPTION;
4278 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4284 Py_DECREF_IMMORTAL(result);
4287 f = PyBytes_Type.tp_richcompare;
4289 PyObject *result = (*f)(operand2, operand1, Py_GT);
4291 if (result != Py_NotImplemented) {
4292 Py_LeaveRecursiveCall();
4294 if (unlikely(result == NULL)) {
4295 return NUITKA_BOOL_EXCEPTION;
4299 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4305 Py_DECREF_IMMORTAL(result);
4310 if (PyInstance_Check(operand1)) {
4311 cmpfunc fcmp = type1->tp_compare;
4312 c = (*fcmp)(operand1, operand2);
4314 cmpfunc fcmp = NULL;
4315 c = (*fcmp)(operand1, operand2);
4317 c = try_3way_compare(operand1, operand2);
4321 if (type1 == &PyBytes_Type) {
4322 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4323 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4325 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4326 }
else if (operand1 == Py_None) {
4329 }
else if (operand2 == Py_None) {
4332 }
else if (PyNumber_Check(operand1)) {
4335 if (PyNumber_Check(operand2)) {
4337 Py_uintptr_t aa = (Py_uintptr_t)type1;
4338 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
4340 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4344 }
else if (PyNumber_Check(operand2)) {
4348 int s = strcmp(type1->tp_name,
"bytes");
4356 Py_uintptr_t aa = (Py_uintptr_t)type1;
4357 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
4359 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4364 Py_LeaveRecursiveCall();
4366 if (unlikely(c <= -2)) {
4367 return NUITKA_BOOL_EXCEPTION;
4392 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4396 bool checked_reverse_op =
false;
4399 if (type1 != &PyBytes_Type && Nuitka_Type_IsSubtype(&PyBytes_Type, type1)) {
4400 f = PyBytes_Type.tp_richcompare;
4403 checked_reverse_op =
true;
4405 PyObject *result = (*f)(operand2, operand1, Py_GT);
4407 if (result != Py_NotImplemented) {
4408 Py_LeaveRecursiveCall();
4410 if (unlikely(result == NULL)) {
4411 return NUITKA_BOOL_EXCEPTION;
4415 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4421 Py_DECREF_IMMORTAL(result);
4425 f = TP_RICHCOMPARE(type1);
4428 PyObject *result = (*f)(operand1, operand2, Py_LT);
4430 if (result != Py_NotImplemented) {
4431 Py_LeaveRecursiveCall();
4433 if (unlikely(result == NULL)) {
4434 return NUITKA_BOOL_EXCEPTION;
4438 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4444 Py_DECREF_IMMORTAL(result);
4447 if (checked_reverse_op ==
false) {
4448 f = PyBytes_Type.tp_richcompare;
4451 PyObject *result = (*f)(operand2, operand1, Py_GT);
4453 if (result != Py_NotImplemented) {
4454 Py_LeaveRecursiveCall();
4456 if (unlikely(result == NULL)) {
4457 return NUITKA_BOOL_EXCEPTION;
4461 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4467 Py_DECREF_IMMORTAL(result);
4471 Py_LeaveRecursiveCall();
4477 bool r = operand1 == operand2;
4478 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4483 bool r = operand1 != operand2;
4484 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4489#if PYTHON_VERSION < 0x360
4490 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < bytes()", type1->tp_name);
4492 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'bytes'", type1->tp_name);
4494 return NUITKA_BOOL_EXCEPTION;
4500#if PYTHON_VERSION >= 0x300
4502nuitka_bool RICH_COMPARE_LT_NBOOL_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
4504 if (&PyBytes_Type == Py_TYPE(operand2)) {
4505 return COMPARE_LT_CBOOL_BYTES_BYTES(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4508#if PYTHON_VERSION < 0x300
4509 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4510 return NUITKA_BOOL_EXCEPTION;
4513 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4514 return NUITKA_BOOL_EXCEPTION;
4518 PyTypeObject *type2 = Py_TYPE(operand2);
4520#if PYTHON_VERSION < 0x300
4522 if (&PyBytes_Type == type2 && !0) {
4524 richcmpfunc frich = PyBytes_Type.tp_richcompare;
4526 if (frich != NULL) {
4527 PyObject *result = (*frich)(operand1, operand2, Py_LT);
4529 if (result != Py_NotImplemented) {
4530 Py_LeaveRecursiveCall();
4532 if (unlikely(result == NULL)) {
4533 return NUITKA_BOOL_EXCEPTION;
4537 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4543 Py_DECREF_IMMORTAL(result);
4547 cmpfunc fcmp = NULL;
4550 int c = (*fcmp)(operand1, operand2);
4551 c = adjust_tp_compare(c);
4553 Py_LeaveRecursiveCall();
4556 return NUITKA_BOOL_EXCEPTION;
4579 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4583 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4592 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4593 f = TP_RICHCOMPARE(type2);
4596 PyObject *result = (*f)(operand2, operand1, Py_GT);
4598 if (result != Py_NotImplemented) {
4599 Py_LeaveRecursiveCall();
4601 if (unlikely(result == NULL)) {
4602 return NUITKA_BOOL_EXCEPTION;
4606 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4612 Py_DECREF_IMMORTAL(result);
4616 f = PyBytes_Type.tp_richcompare;
4618 PyObject *result = (*f)(operand1, operand2, Py_LT);
4620 if (result != Py_NotImplemented) {
4621 Py_LeaveRecursiveCall();
4623 if (unlikely(result == NULL)) {
4624 return NUITKA_BOOL_EXCEPTION;
4628 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4634 Py_DECREF_IMMORTAL(result);
4637 f = TP_RICHCOMPARE(type2);
4639 PyObject *result = (*f)(operand2, operand1, Py_GT);
4641 if (result != Py_NotImplemented) {
4642 Py_LeaveRecursiveCall();
4644 if (unlikely(result == NULL)) {
4645 return NUITKA_BOOL_EXCEPTION;
4649 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4655 Py_DECREF_IMMORTAL(result);
4661 cmpfunc fcmp = NULL;
4662 c = (*fcmp)(operand1, operand2);
4663 }
else if (PyInstance_Check(operand2)) {
4664 cmpfunc fcmp = type2->tp_compare;
4665 c = (*fcmp)(operand1, operand2);
4667 c = try_3way_compare(operand1, operand2);
4671 if (&PyBytes_Type == type2) {
4672 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4673 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4675 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4676 }
else if (operand1 == Py_None) {
4679 }
else if (operand2 == Py_None) {
4682 }
else if (PyNumber_Check(operand1)) {
4685 if (PyNumber_Check(operand2)) {
4687 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4688 Py_uintptr_t bb = (Py_uintptr_t)type2;
4690 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4694 }
else if (PyNumber_Check(operand2)) {
4698 int s = strcmp(
"bytes", type2->tp_name);
4706 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4707 Py_uintptr_t bb = (Py_uintptr_t)type2;
4709 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4714 Py_LeaveRecursiveCall();
4716 if (unlikely(c <= -2)) {
4717 return NUITKA_BOOL_EXCEPTION;
4742 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4746 bool checked_reverse_op =
false;
4749 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4750 f = TP_RICHCOMPARE(type2);
4753 checked_reverse_op =
true;
4755 PyObject *result = (*f)(operand2, operand1, Py_GT);
4757 if (result != Py_NotImplemented) {
4758 Py_LeaveRecursiveCall();
4760 if (unlikely(result == NULL)) {
4761 return NUITKA_BOOL_EXCEPTION;
4765 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4771 Py_DECREF_IMMORTAL(result);
4775 f = PyBytes_Type.tp_richcompare;
4778 PyObject *result = (*f)(operand1, operand2, Py_LT);
4780 if (result != Py_NotImplemented) {
4781 Py_LeaveRecursiveCall();
4783 if (unlikely(result == NULL)) {
4784 return NUITKA_BOOL_EXCEPTION;
4788 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4794 Py_DECREF_IMMORTAL(result);
4797 if (checked_reverse_op ==
false) {
4798 f = TP_RICHCOMPARE(type2);
4801 PyObject *result = (*f)(operand2, operand1, Py_GT);
4803 if (result != Py_NotImplemented) {
4804 Py_LeaveRecursiveCall();
4806 if (unlikely(result == NULL)) {
4807 return NUITKA_BOOL_EXCEPTION;
4811 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4817 Py_DECREF_IMMORTAL(result);
4821 Py_LeaveRecursiveCall();
4827 bool r = operand1 == operand2;
4828 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4833 bool r = operand1 != operand2;
4834 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4839#if PYTHON_VERSION < 0x360
4840 PyErr_Format(PyExc_TypeError,
"unorderable types: bytes() < %s()", type2->tp_name);
4842 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'bytes' and '%s'", type2->tp_name);
4844 return NUITKA_BOOL_EXCEPTION;
4850#if PYTHON_VERSION < 0x300
4852PyObject *RICH_COMPARE_LT_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
4854 if (Py_TYPE(operand1) == &PyInt_Type) {
4855 return COMPARE_LT_OBJECT_INT_INT(operand1, operand2);
4858#if PYTHON_VERSION < 0x300
4859 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4863 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4868 PyTypeObject *type1 = Py_TYPE(operand1);
4870#if PYTHON_VERSION < 0x300
4872 if (type1 == &PyInt_Type && !0) {
4874 richcmpfunc frich = NULL;
4876 if (frich != NULL) {
4877 PyObject *result = (*frich)(operand1, operand2, Py_LT);
4879 if (result != Py_NotImplemented) {
4880 Py_LeaveRecursiveCall();
4885 Py_DECREF_IMMORTAL(result);
4889 cmpfunc fcmp = PyInt_Type.tp_compare;
4892 int c = (*fcmp)(operand1, operand2);
4893 c = adjust_tp_compare(c);
4895 Py_LeaveRecursiveCall();
4921 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4925 PyObject *result = BOOL_FROM(r);
4926 Py_INCREF_IMMORTAL(result);
4934 if (type1 != &PyInt_Type && 0) {
4938 PyObject *result = (*f)(operand2, operand1, Py_GT);
4940 if (result != Py_NotImplemented) {
4941 Py_LeaveRecursiveCall();
4946 Py_DECREF_IMMORTAL(result);
4950 f = TP_RICHCOMPARE(type1);
4952 PyObject *result = (*f)(operand1, operand2, Py_LT);
4954 if (result != Py_NotImplemented) {
4955 Py_LeaveRecursiveCall();
4960 Py_DECREF_IMMORTAL(result);
4965 PyObject *result = (*f)(operand2, operand1, Py_GT);
4967 if (result != Py_NotImplemented) {
4968 Py_LeaveRecursiveCall();
4973 Py_DECREF_IMMORTAL(result);
4978 if (PyInstance_Check(operand1)) {
4979 cmpfunc fcmp = type1->tp_compare;
4980 c = (*fcmp)(operand1, operand2);
4982 cmpfunc fcmp = PyInt_Type.tp_compare;
4983 c = (*fcmp)(operand1, operand2);
4985 c = try_3way_compare(operand1, operand2);
4989 if (type1 == &PyInt_Type) {
4990 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4991 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4993 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4994 }
else if (operand1 == Py_None) {
4997 }
else if (operand2 == Py_None) {
5000 }
else if (PyNumber_Check(operand1)) {
5003 if (PyNumber_Check(operand2)) {
5005 Py_uintptr_t aa = (Py_uintptr_t)type1;
5006 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5008 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5012 }
else if (PyNumber_Check(operand2)) {
5016 int s = strcmp(type1->tp_name,
"int");
5024 Py_uintptr_t aa = (Py_uintptr_t)type1;
5025 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5027 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5032 Py_LeaveRecursiveCall();
5034 if (unlikely(c <= -2)) {
5060 PyObject *result = BOOL_FROM(r);
5061 Py_INCREF_IMMORTAL(result);
5064 bool checked_reverse_op =
false;
5067 if (type1 != &PyInt_Type && Nuitka_Type_IsSubtype(&PyInt_Type, type1)) {
5071 checked_reverse_op =
true;
5073 PyObject *result = (*f)(operand2, operand1, Py_GT);
5075 if (result != Py_NotImplemented) {
5076 Py_LeaveRecursiveCall();
5081 Py_DECREF_IMMORTAL(result);
5085 f = TP_RICHCOMPARE(type1);
5088 PyObject *result = (*f)(operand1, operand2, Py_LT);
5090 if (result != Py_NotImplemented) {
5091 Py_LeaveRecursiveCall();
5096 Py_DECREF_IMMORTAL(result);
5099 if (checked_reverse_op ==
false) {
5103 PyObject *result = (*f)(operand2, operand1, Py_GT);
5105 if (result != Py_NotImplemented) {
5106 Py_LeaveRecursiveCall();
5111 Py_DECREF_IMMORTAL(result);
5115 Py_LeaveRecursiveCall();
5121 bool r = operand1 == operand2;
5122 PyObject *result = BOOL_FROM(r);
5123 Py_INCREF_IMMORTAL(result);
5127 bool r = operand1 != operand2;
5128 PyObject *result = BOOL_FROM(r);
5129 Py_INCREF_IMMORTAL(result);
5133#if PYTHON_VERSION < 0x360
5134 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < int()", type1->tp_name);
5136 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'int'", type1->tp_name);
5144#if PYTHON_VERSION < 0x300
5146PyObject *RICH_COMPARE_LT_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
5148 if (&PyInt_Type == Py_TYPE(operand2)) {
5149 return COMPARE_LT_OBJECT_INT_INT(operand1, operand2);
5152#if PYTHON_VERSION < 0x300
5153 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5157 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5162 PyTypeObject *type2 = Py_TYPE(operand2);
5164#if PYTHON_VERSION < 0x300
5166 if (&PyInt_Type == type2 && !0) {
5168 richcmpfunc frich = NULL;
5170 if (frich != NULL) {
5171 PyObject *result = (*frich)(operand1, operand2, Py_LT);
5173 if (result != Py_NotImplemented) {
5174 Py_LeaveRecursiveCall();
5179 Py_DECREF_IMMORTAL(result);
5183 cmpfunc fcmp = PyInt_Type.tp_compare;
5186 int c = (*fcmp)(operand1, operand2);
5187 c = adjust_tp_compare(c);
5189 Py_LeaveRecursiveCall();
5215 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5219 PyObject *result = BOOL_FROM(r);
5220 Py_INCREF_IMMORTAL(result);
5228 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5229 f = TP_RICHCOMPARE(type2);
5232 PyObject *result = (*f)(operand2, operand1, Py_GT);
5234 if (result != Py_NotImplemented) {
5235 Py_LeaveRecursiveCall();
5240 Py_DECREF_IMMORTAL(result);
5246 PyObject *result = (*f)(operand1, operand2, Py_LT);
5248 if (result != Py_NotImplemented) {
5249 Py_LeaveRecursiveCall();
5254 Py_DECREF_IMMORTAL(result);
5257 f = TP_RICHCOMPARE(type2);
5259 PyObject *result = (*f)(operand2, operand1, Py_GT);
5261 if (result != Py_NotImplemented) {
5262 Py_LeaveRecursiveCall();
5267 Py_DECREF_IMMORTAL(result);
5273 cmpfunc fcmp = PyInt_Type.tp_compare;
5274 c = (*fcmp)(operand1, operand2);
5275 }
else if (PyInstance_Check(operand2)) {
5276 cmpfunc fcmp = type2->tp_compare;
5277 c = (*fcmp)(operand1, operand2);
5279 c = try_3way_compare(operand1, operand2);
5283 if (&PyInt_Type == type2) {
5284 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5285 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5287 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5288 }
else if (operand1 == Py_None) {
5291 }
else if (operand2 == Py_None) {
5294 }
else if (PyNumber_Check(operand1)) {
5297 if (PyNumber_Check(operand2)) {
5299 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5300 Py_uintptr_t bb = (Py_uintptr_t)type2;
5302 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5306 }
else if (PyNumber_Check(operand2)) {
5310 int s = strcmp(
"int", type2->tp_name);
5318 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5319 Py_uintptr_t bb = (Py_uintptr_t)type2;
5321 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5326 Py_LeaveRecursiveCall();
5328 if (unlikely(c <= -2)) {
5354 PyObject *result = BOOL_FROM(r);
5355 Py_INCREF_IMMORTAL(result);
5358 bool checked_reverse_op =
false;
5361 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5362 f = TP_RICHCOMPARE(type2);
5365 checked_reverse_op =
true;
5367 PyObject *result = (*f)(operand2, operand1, Py_GT);
5369 if (result != Py_NotImplemented) {
5370 Py_LeaveRecursiveCall();
5375 Py_DECREF_IMMORTAL(result);
5382 PyObject *result = (*f)(operand1, operand2, Py_LT);
5384 if (result != Py_NotImplemented) {
5385 Py_LeaveRecursiveCall();
5390 Py_DECREF_IMMORTAL(result);
5393 if (checked_reverse_op ==
false) {
5394 f = TP_RICHCOMPARE(type2);
5397 PyObject *result = (*f)(operand2, operand1, Py_GT);
5399 if (result != Py_NotImplemented) {
5400 Py_LeaveRecursiveCall();
5405 Py_DECREF_IMMORTAL(result);
5409 Py_LeaveRecursiveCall();
5415 bool r = operand1 == operand2;
5416 PyObject *result = BOOL_FROM(r);
5417 Py_INCREF_IMMORTAL(result);
5421 bool r = operand1 != operand2;
5422 PyObject *result = BOOL_FROM(r);
5423 Py_INCREF_IMMORTAL(result);
5427#if PYTHON_VERSION < 0x360
5428 PyErr_Format(PyExc_TypeError,
"unorderable types: int() < %s()", type2->tp_name);
5430 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'int' and '%s'", type2->tp_name);
5438#if PYTHON_VERSION < 0x300
5440PyObject *RICH_COMPARE_LT_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
5442 return COMPARE_LT_OBJECT_INT_INT(operand1, operand2);
5446#if PYTHON_VERSION < 0x300
5448bool RICH_COMPARE_LT_CBOOL_INT_INT(PyObject *operand1, PyObject *operand2) {
5450 return COMPARE_LT_CBOOL_INT_INT(operand1, operand2);
5454#if PYTHON_VERSION < 0x300
5456nuitka_bool RICH_COMPARE_LT_NBOOL_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
5458 if (Py_TYPE(operand1) == &PyInt_Type) {
5459 return COMPARE_LT_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5462#if PYTHON_VERSION < 0x300
5463 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5464 return NUITKA_BOOL_EXCEPTION;
5467 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5468 return NUITKA_BOOL_EXCEPTION;
5472 PyTypeObject *type1 = Py_TYPE(operand1);
5474#if PYTHON_VERSION < 0x300
5476 if (type1 == &PyInt_Type && !0) {
5478 richcmpfunc frich = NULL;
5480 if (frich != NULL) {
5481 PyObject *result = (*frich)(operand1, operand2, Py_LT);
5483 if (result != Py_NotImplemented) {
5484 Py_LeaveRecursiveCall();
5486 if (unlikely(result == NULL)) {
5487 return NUITKA_BOOL_EXCEPTION;
5491 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5497 Py_DECREF_IMMORTAL(result);
5501 cmpfunc fcmp = PyInt_Type.tp_compare;
5504 int c = (*fcmp)(operand1, operand2);
5505 c = adjust_tp_compare(c);
5507 Py_LeaveRecursiveCall();
5510 return NUITKA_BOOL_EXCEPTION;
5533 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5537 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5546 if (type1 != &PyInt_Type && 0) {
5550 PyObject *result = (*f)(operand2, operand1, Py_GT);
5552 if (result != Py_NotImplemented) {
5553 Py_LeaveRecursiveCall();
5555 if (unlikely(result == NULL)) {
5556 return NUITKA_BOOL_EXCEPTION;
5560 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5566 Py_DECREF_IMMORTAL(result);
5570 f = TP_RICHCOMPARE(type1);
5572 PyObject *result = (*f)(operand1, operand2, Py_LT);
5574 if (result != Py_NotImplemented) {
5575 Py_LeaveRecursiveCall();
5577 if (unlikely(result == NULL)) {
5578 return NUITKA_BOOL_EXCEPTION;
5582 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5588 Py_DECREF_IMMORTAL(result);
5593 PyObject *result = (*f)(operand2, operand1, Py_GT);
5595 if (result != Py_NotImplemented) {
5596 Py_LeaveRecursiveCall();
5598 if (unlikely(result == NULL)) {
5599 return NUITKA_BOOL_EXCEPTION;
5603 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5609 Py_DECREF_IMMORTAL(result);
5614 if (PyInstance_Check(operand1)) {
5615 cmpfunc fcmp = type1->tp_compare;
5616 c = (*fcmp)(operand1, operand2);
5618 cmpfunc fcmp = PyInt_Type.tp_compare;
5619 c = (*fcmp)(operand1, operand2);
5621 c = try_3way_compare(operand1, operand2);
5625 if (type1 == &PyInt_Type) {
5626 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5627 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5629 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5630 }
else if (operand1 == Py_None) {
5633 }
else if (operand2 == Py_None) {
5636 }
else if (PyNumber_Check(operand1)) {
5639 if (PyNumber_Check(operand2)) {
5641 Py_uintptr_t aa = (Py_uintptr_t)type1;
5642 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5644 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5648 }
else if (PyNumber_Check(operand2)) {
5652 int s = strcmp(type1->tp_name,
"int");
5660 Py_uintptr_t aa = (Py_uintptr_t)type1;
5661 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5663 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5668 Py_LeaveRecursiveCall();
5670 if (unlikely(c <= -2)) {
5671 return NUITKA_BOOL_EXCEPTION;
5696 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5700 bool checked_reverse_op =
false;
5703 if (type1 != &PyInt_Type && Nuitka_Type_IsSubtype(&PyInt_Type, type1)) {
5707 checked_reverse_op =
true;
5709 PyObject *result = (*f)(operand2, operand1, Py_GT);
5711 if (result != Py_NotImplemented) {
5712 Py_LeaveRecursiveCall();
5714 if (unlikely(result == NULL)) {
5715 return NUITKA_BOOL_EXCEPTION;
5719 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5725 Py_DECREF_IMMORTAL(result);
5729 f = TP_RICHCOMPARE(type1);
5732 PyObject *result = (*f)(operand1, operand2, Py_LT);
5734 if (result != Py_NotImplemented) {
5735 Py_LeaveRecursiveCall();
5737 if (unlikely(result == NULL)) {
5738 return NUITKA_BOOL_EXCEPTION;
5742 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5748 Py_DECREF_IMMORTAL(result);
5751 if (checked_reverse_op ==
false) {
5755 PyObject *result = (*f)(operand2, operand1, Py_GT);
5757 if (result != Py_NotImplemented) {
5758 Py_LeaveRecursiveCall();
5760 if (unlikely(result == NULL)) {
5761 return NUITKA_BOOL_EXCEPTION;
5765 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5771 Py_DECREF_IMMORTAL(result);
5775 Py_LeaveRecursiveCall();
5781 bool r = operand1 == operand2;
5782 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5787 bool r = operand1 != operand2;
5788 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5793#if PYTHON_VERSION < 0x360
5794 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < int()", type1->tp_name);
5796 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'int'", type1->tp_name);
5798 return NUITKA_BOOL_EXCEPTION;
5804#if PYTHON_VERSION < 0x300
5806nuitka_bool RICH_COMPARE_LT_NBOOL_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
5808 if (&PyInt_Type == Py_TYPE(operand2)) {
5809 return COMPARE_LT_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5812#if PYTHON_VERSION < 0x300
5813 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5814 return NUITKA_BOOL_EXCEPTION;
5817 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5818 return NUITKA_BOOL_EXCEPTION;
5822 PyTypeObject *type2 = Py_TYPE(operand2);
5824#if PYTHON_VERSION < 0x300
5826 if (&PyInt_Type == type2 && !0) {
5828 richcmpfunc frich = NULL;
5830 if (frich != NULL) {
5831 PyObject *result = (*frich)(operand1, operand2, Py_LT);
5833 if (result != Py_NotImplemented) {
5834 Py_LeaveRecursiveCall();
5836 if (unlikely(result == NULL)) {
5837 return NUITKA_BOOL_EXCEPTION;
5841 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5847 Py_DECREF_IMMORTAL(result);
5851 cmpfunc fcmp = PyInt_Type.tp_compare;
5854 int c = (*fcmp)(operand1, operand2);
5855 c = adjust_tp_compare(c);
5857 Py_LeaveRecursiveCall();
5860 return NUITKA_BOOL_EXCEPTION;
5883 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5887 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5896 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5897 f = TP_RICHCOMPARE(type2);
5900 PyObject *result = (*f)(operand2, operand1, Py_GT);
5902 if (result != Py_NotImplemented) {
5903 Py_LeaveRecursiveCall();
5905 if (unlikely(result == NULL)) {
5906 return NUITKA_BOOL_EXCEPTION;
5910 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5916 Py_DECREF_IMMORTAL(result);
5922 PyObject *result = (*f)(operand1, operand2, Py_LT);
5924 if (result != Py_NotImplemented) {
5925 Py_LeaveRecursiveCall();
5927 if (unlikely(result == NULL)) {
5928 return NUITKA_BOOL_EXCEPTION;
5932 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5938 Py_DECREF_IMMORTAL(result);
5941 f = TP_RICHCOMPARE(type2);
5943 PyObject *result = (*f)(operand2, operand1, Py_GT);
5945 if (result != Py_NotImplemented) {
5946 Py_LeaveRecursiveCall();
5948 if (unlikely(result == NULL)) {
5949 return NUITKA_BOOL_EXCEPTION;
5953 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5959 Py_DECREF_IMMORTAL(result);
5965 cmpfunc fcmp = PyInt_Type.tp_compare;
5966 c = (*fcmp)(operand1, operand2);
5967 }
else if (PyInstance_Check(operand2)) {
5968 cmpfunc fcmp = type2->tp_compare;
5969 c = (*fcmp)(operand1, operand2);
5971 c = try_3way_compare(operand1, operand2);
5975 if (&PyInt_Type == type2) {
5976 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5977 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5979 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5980 }
else if (operand1 == Py_None) {
5983 }
else if (operand2 == Py_None) {
5986 }
else if (PyNumber_Check(operand1)) {
5989 if (PyNumber_Check(operand2)) {
5991 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5992 Py_uintptr_t bb = (Py_uintptr_t)type2;
5994 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5998 }
else if (PyNumber_Check(operand2)) {
6002 int s = strcmp(
"int", type2->tp_name);
6010 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
6011 Py_uintptr_t bb = (Py_uintptr_t)type2;
6013 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6018 Py_LeaveRecursiveCall();
6020 if (unlikely(c <= -2)) {
6021 return NUITKA_BOOL_EXCEPTION;
6046 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6050 bool checked_reverse_op =
false;
6053 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
6054 f = TP_RICHCOMPARE(type2);
6057 checked_reverse_op =
true;
6059 PyObject *result = (*f)(operand2, operand1, Py_GT);
6061 if (result != Py_NotImplemented) {
6062 Py_LeaveRecursiveCall();
6064 if (unlikely(result == NULL)) {
6065 return NUITKA_BOOL_EXCEPTION;
6069 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6075 Py_DECREF_IMMORTAL(result);
6082 PyObject *result = (*f)(operand1, operand2, Py_LT);
6084 if (result != Py_NotImplemented) {
6085 Py_LeaveRecursiveCall();
6087 if (unlikely(result == NULL)) {
6088 return NUITKA_BOOL_EXCEPTION;
6092 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6098 Py_DECREF_IMMORTAL(result);
6101 if (checked_reverse_op ==
false) {
6102 f = TP_RICHCOMPARE(type2);
6105 PyObject *result = (*f)(operand2, operand1, Py_GT);
6107 if (result != Py_NotImplemented) {
6108 Py_LeaveRecursiveCall();
6110 if (unlikely(result == NULL)) {
6111 return NUITKA_BOOL_EXCEPTION;
6115 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6121 Py_DECREF_IMMORTAL(result);
6125 Py_LeaveRecursiveCall();
6131 bool r = operand1 == operand2;
6132 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6137 bool r = operand1 != operand2;
6138 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6143#if PYTHON_VERSION < 0x360
6144 PyErr_Format(PyExc_TypeError,
"unorderable types: int() < %s()", type2->tp_name);
6146 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'int' and '%s'", type2->tp_name);
6148 return NUITKA_BOOL_EXCEPTION;
6154static PyObject *COMPARE_LT_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6155 CHECK_OBJECT(operand1);
6156 assert(PyLong_CheckExact(operand1));
6157 CHECK_OBJECT(operand2);
6158 assert(PyLong_CheckExact(operand2));
6160 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
6162 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
6166 if (operand1_long_object == operand2_long_object) {
6168 }
else if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
6169 Nuitka_LongGetSignedDigitSize(operand2_long_object)) {
6170 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - Nuitka_LongGetSignedDigitSize(operand2_long_object) <
6173 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
6176 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] !=
6177 Nuitka_LongGetDigitPointer(operand2_long_object)[i]) {
6178 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] <
6179 Nuitka_LongGetDigitPointer(operand2_long_object)[i];
6180 if (Nuitka_LongIsNegative(operand1_long_object)) {
6189 PyObject *result = BOOL_FROM(r);
6190 Py_INCREF_IMMORTAL(result);
6194PyObject *RICH_COMPARE_LT_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
6196 if (Py_TYPE(operand1) == &PyLong_Type) {
6197 return COMPARE_LT_OBJECT_LONG_LONG(operand1, operand2);
6200#if PYTHON_VERSION < 0x300
6201 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6205 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6210 PyTypeObject *type1 = Py_TYPE(operand1);
6212#if PYTHON_VERSION < 0x300
6214 if (type1 == &PyLong_Type && !0) {
6216 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6218 if (frich != NULL) {
6219 PyObject *result = (*frich)(operand1, operand2, Py_LT);
6221 if (result != Py_NotImplemented) {
6222 Py_LeaveRecursiveCall();
6227 Py_DECREF_IMMORTAL(result);
6231 cmpfunc fcmp = PyLong_Type.tp_compare;
6234 int c = (*fcmp)(operand1, operand2);
6235 c = adjust_tp_compare(c);
6237 Py_LeaveRecursiveCall();
6263 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6267 PyObject *result = BOOL_FROM(r);
6268 Py_INCREF_IMMORTAL(result);
6276 if (type1 != &PyLong_Type && 0) {
6277 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6280 PyObject *result = (*f)(operand2, operand1, Py_GT);
6282 if (result != Py_NotImplemented) {
6283 Py_LeaveRecursiveCall();
6288 Py_DECREF_IMMORTAL(result);
6292 f = TP_RICHCOMPARE(type1);
6294 PyObject *result = (*f)(operand1, operand2, Py_LT);
6296 if (result != Py_NotImplemented) {
6297 Py_LeaveRecursiveCall();
6302 Py_DECREF_IMMORTAL(result);
6305 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6307 PyObject *result = (*f)(operand2, operand1, Py_GT);
6309 if (result != Py_NotImplemented) {
6310 Py_LeaveRecursiveCall();
6315 Py_DECREF_IMMORTAL(result);
6320 if (PyInstance_Check(operand1)) {
6321 cmpfunc fcmp = type1->tp_compare;
6322 c = (*fcmp)(operand1, operand2);
6324 cmpfunc fcmp = PyLong_Type.tp_compare;
6325 c = (*fcmp)(operand1, operand2);
6327 c = try_3way_compare(operand1, operand2);
6331 if (type1 == &PyLong_Type) {
6332 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6333 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6335 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6336 }
else if (operand1 == Py_None) {
6339 }
else if (operand2 == Py_None) {
6342 }
else if (PyNumber_Check(operand1)) {
6345 if (PyNumber_Check(operand2)) {
6347 Py_uintptr_t aa = (Py_uintptr_t)type1;
6348 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6350 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6354 }
else if (PyNumber_Check(operand2)) {
6358 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"long" :
"int"));
6366 Py_uintptr_t aa = (Py_uintptr_t)type1;
6367 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6369 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6374 Py_LeaveRecursiveCall();
6376 if (unlikely(c <= -2)) {
6402 PyObject *result = BOOL_FROM(r);
6403 Py_INCREF_IMMORTAL(result);
6406 bool checked_reverse_op =
false;
6409 if (type1 != &PyLong_Type && Nuitka_Type_IsSubtype(&PyLong_Type, type1)) {
6410 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6413 checked_reverse_op =
true;
6415 PyObject *result = (*f)(operand2, operand1, Py_GT);
6417 if (result != Py_NotImplemented) {
6418 Py_LeaveRecursiveCall();
6423 Py_DECREF_IMMORTAL(result);
6427 f = TP_RICHCOMPARE(type1);
6430 PyObject *result = (*f)(operand1, operand2, Py_LT);
6432 if (result != Py_NotImplemented) {
6433 Py_LeaveRecursiveCall();
6438 Py_DECREF_IMMORTAL(result);
6441 if (checked_reverse_op ==
false) {
6442 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6445 PyObject *result = (*f)(operand2, operand1, Py_GT);
6447 if (result != Py_NotImplemented) {
6448 Py_LeaveRecursiveCall();
6453 Py_DECREF_IMMORTAL(result);
6457 Py_LeaveRecursiveCall();
6463 bool r = operand1 == operand2;
6464 PyObject *result = BOOL_FROM(r);
6465 Py_INCREF_IMMORTAL(result);
6469 bool r = operand1 != operand2;
6470 PyObject *result = BOOL_FROM(r);
6471 Py_INCREF_IMMORTAL(result);
6475#if PYTHON_VERSION < 0x300
6476 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < long()", type1->tp_name);
6477#elif PYTHON_VERSION < 0x360
6478 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < int()", type1->tp_name);
6480 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'int'", type1->tp_name);
6488PyObject *RICH_COMPARE_LT_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
6490 if (&PyLong_Type == Py_TYPE(operand2)) {
6491 return COMPARE_LT_OBJECT_LONG_LONG(operand1, operand2);
6494#if PYTHON_VERSION < 0x300
6495 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6499 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6504 PyTypeObject *type2 = Py_TYPE(operand2);
6506#if PYTHON_VERSION < 0x300
6508 if (&PyLong_Type == type2 && !0) {
6510 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6512 if (frich != NULL) {
6513 PyObject *result = (*frich)(operand1, operand2, Py_LT);
6515 if (result != Py_NotImplemented) {
6516 Py_LeaveRecursiveCall();
6521 Py_DECREF_IMMORTAL(result);
6525 cmpfunc fcmp = PyLong_Type.tp_compare;
6528 int c = (*fcmp)(operand1, operand2);
6529 c = adjust_tp_compare(c);
6531 Py_LeaveRecursiveCall();
6557 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6561 PyObject *result = BOOL_FROM(r);
6562 Py_INCREF_IMMORTAL(result);
6570 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
6571 f = TP_RICHCOMPARE(type2);
6574 PyObject *result = (*f)(operand2, operand1, Py_GT);
6576 if (result != Py_NotImplemented) {
6577 Py_LeaveRecursiveCall();
6582 Py_DECREF_IMMORTAL(result);
6586 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6588 PyObject *result = (*f)(operand1, operand2, Py_LT);
6590 if (result != Py_NotImplemented) {
6591 Py_LeaveRecursiveCall();
6596 Py_DECREF_IMMORTAL(result);
6599 f = TP_RICHCOMPARE(type2);
6601 PyObject *result = (*f)(operand2, operand1, Py_GT);
6603 if (result != Py_NotImplemented) {
6604 Py_LeaveRecursiveCall();
6609 Py_DECREF_IMMORTAL(result);
6615 cmpfunc fcmp = PyLong_Type.tp_compare;
6616 c = (*fcmp)(operand1, operand2);
6617 }
else if (PyInstance_Check(operand2)) {
6618 cmpfunc fcmp = type2->tp_compare;
6619 c = (*fcmp)(operand1, operand2);
6621 c = try_3way_compare(operand1, operand2);
6625 if (&PyLong_Type == type2) {
6626 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6627 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6629 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6630 }
else if (operand1 == Py_None) {
6633 }
else if (operand2 == Py_None) {
6636 }
else if (PyNumber_Check(operand1)) {
6639 if (PyNumber_Check(operand2)) {
6641 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
6642 Py_uintptr_t bb = (Py_uintptr_t)type2;
6644 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6648 }
else if (PyNumber_Check(operand2)) {
6652 int s = strcmp((PYTHON_VERSION < 0x300 ?
"long" :
"int"), type2->tp_name);
6660 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
6661 Py_uintptr_t bb = (Py_uintptr_t)type2;
6663 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6668 Py_LeaveRecursiveCall();
6670 if (unlikely(c <= -2)) {
6696 PyObject *result = BOOL_FROM(r);
6697 Py_INCREF_IMMORTAL(result);
6700 bool checked_reverse_op =
false;
6703 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
6704 f = TP_RICHCOMPARE(type2);
6707 checked_reverse_op =
true;
6709 PyObject *result = (*f)(operand2, operand1, Py_GT);
6711 if (result != Py_NotImplemented) {
6712 Py_LeaveRecursiveCall();
6717 Py_DECREF_IMMORTAL(result);
6721 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6724 PyObject *result = (*f)(operand1, operand2, Py_LT);
6726 if (result != Py_NotImplemented) {
6727 Py_LeaveRecursiveCall();
6732 Py_DECREF_IMMORTAL(result);
6735 if (checked_reverse_op ==
false) {
6736 f = TP_RICHCOMPARE(type2);
6739 PyObject *result = (*f)(operand2, operand1, Py_GT);
6741 if (result != Py_NotImplemented) {
6742 Py_LeaveRecursiveCall();
6747 Py_DECREF_IMMORTAL(result);
6751 Py_LeaveRecursiveCall();
6757 bool r = operand1 == operand2;
6758 PyObject *result = BOOL_FROM(r);
6759 Py_INCREF_IMMORTAL(result);
6763 bool r = operand1 != operand2;
6764 PyObject *result = BOOL_FROM(r);
6765 Py_INCREF_IMMORTAL(result);
6769#if PYTHON_VERSION < 0x300
6770 PyErr_Format(PyExc_TypeError,
"unorderable types: long() < %s()", type2->tp_name);
6771#elif PYTHON_VERSION < 0x360
6772 PyErr_Format(PyExc_TypeError,
"unorderable types: int() < %s()", type2->tp_name);
6774 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'int' and '%s'", type2->tp_name);
6782PyObject *RICH_COMPARE_LT_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6784 return COMPARE_LT_OBJECT_LONG_LONG(operand1, operand2);
6787static bool COMPARE_LT_CBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6788 CHECK_OBJECT(operand1);
6789 assert(PyLong_CheckExact(operand1));
6790 CHECK_OBJECT(operand2);
6791 assert(PyLong_CheckExact(operand2));
6793 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
6795 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
6799 if (operand1_long_object == operand2_long_object) {
6801 }
else if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
6802 Nuitka_LongGetSignedDigitSize(operand2_long_object)) {
6803 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - Nuitka_LongGetSignedDigitSize(operand2_long_object) <
6806 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
6809 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] !=
6810 Nuitka_LongGetDigitPointer(operand2_long_object)[i]) {
6811 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] <
6812 Nuitka_LongGetDigitPointer(operand2_long_object)[i];
6813 if (Nuitka_LongIsNegative(operand1_long_object)) {
6827bool RICH_COMPARE_LT_CBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6829 return COMPARE_LT_CBOOL_LONG_LONG(operand1, operand2);
6833nuitka_bool RICH_COMPARE_LT_NBOOL_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
6835 if (Py_TYPE(operand1) == &PyLong_Type) {
6836 return COMPARE_LT_CBOOL_LONG_LONG(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6839#if PYTHON_VERSION < 0x300
6840 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6841 return NUITKA_BOOL_EXCEPTION;
6844 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6845 return NUITKA_BOOL_EXCEPTION;
6849 PyTypeObject *type1 = Py_TYPE(operand1);
6851#if PYTHON_VERSION < 0x300
6853 if (type1 == &PyLong_Type && !0) {
6855 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6857 if (frich != NULL) {
6858 PyObject *result = (*frich)(operand1, operand2, Py_LT);
6860 if (result != Py_NotImplemented) {
6861 Py_LeaveRecursiveCall();
6863 if (unlikely(result == NULL)) {
6864 return NUITKA_BOOL_EXCEPTION;
6868 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6874 Py_DECREF_IMMORTAL(result);
6878 cmpfunc fcmp = PyLong_Type.tp_compare;
6881 int c = (*fcmp)(operand1, operand2);
6882 c = adjust_tp_compare(c);
6884 Py_LeaveRecursiveCall();
6887 return NUITKA_BOOL_EXCEPTION;
6910 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6914 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6923 if (type1 != &PyLong_Type && 0) {
6924 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6927 PyObject *result = (*f)(operand2, operand1, Py_GT);
6929 if (result != Py_NotImplemented) {
6930 Py_LeaveRecursiveCall();
6932 if (unlikely(result == NULL)) {
6933 return NUITKA_BOOL_EXCEPTION;
6937 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6943 Py_DECREF_IMMORTAL(result);
6947 f = TP_RICHCOMPARE(type1);
6949 PyObject *result = (*f)(operand1, operand2, Py_LT);
6951 if (result != Py_NotImplemented) {
6952 Py_LeaveRecursiveCall();
6954 if (unlikely(result == NULL)) {
6955 return NUITKA_BOOL_EXCEPTION;
6959 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6965 Py_DECREF_IMMORTAL(result);
6968 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6970 PyObject *result = (*f)(operand2, operand1, Py_GT);
6972 if (result != Py_NotImplemented) {
6973 Py_LeaveRecursiveCall();
6975 if (unlikely(result == NULL)) {
6976 return NUITKA_BOOL_EXCEPTION;
6980 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6986 Py_DECREF_IMMORTAL(result);
6991 if (PyInstance_Check(operand1)) {
6992 cmpfunc fcmp = type1->tp_compare;
6993 c = (*fcmp)(operand1, operand2);
6995 cmpfunc fcmp = PyLong_Type.tp_compare;
6996 c = (*fcmp)(operand1, operand2);
6998 c = try_3way_compare(operand1, operand2);
7002 if (type1 == &PyLong_Type) {
7003 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7004 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7006 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7007 }
else if (operand1 == Py_None) {
7010 }
else if (operand2 == Py_None) {
7013 }
else if (PyNumber_Check(operand1)) {
7016 if (PyNumber_Check(operand2)) {
7018 Py_uintptr_t aa = (Py_uintptr_t)type1;
7019 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
7021 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7025 }
else if (PyNumber_Check(operand2)) {
7029 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"long" :
"int"));
7037 Py_uintptr_t aa = (Py_uintptr_t)type1;
7038 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
7040 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7045 Py_LeaveRecursiveCall();
7047 if (unlikely(c <= -2)) {
7048 return NUITKA_BOOL_EXCEPTION;
7073 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7077 bool checked_reverse_op =
false;
7080 if (type1 != &PyLong_Type && Nuitka_Type_IsSubtype(&PyLong_Type, type1)) {
7081 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7084 checked_reverse_op =
true;
7086 PyObject *result = (*f)(operand2, operand1, Py_GT);
7088 if (result != Py_NotImplemented) {
7089 Py_LeaveRecursiveCall();
7091 if (unlikely(result == NULL)) {
7092 return NUITKA_BOOL_EXCEPTION;
7096 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7102 Py_DECREF_IMMORTAL(result);
7106 f = TP_RICHCOMPARE(type1);
7109 PyObject *result = (*f)(operand1, operand2, Py_LT);
7111 if (result != Py_NotImplemented) {
7112 Py_LeaveRecursiveCall();
7114 if (unlikely(result == NULL)) {
7115 return NUITKA_BOOL_EXCEPTION;
7119 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7125 Py_DECREF_IMMORTAL(result);
7128 if (checked_reverse_op ==
false) {
7129 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7132 PyObject *result = (*f)(operand2, operand1, Py_GT);
7134 if (result != Py_NotImplemented) {
7135 Py_LeaveRecursiveCall();
7137 if (unlikely(result == NULL)) {
7138 return NUITKA_BOOL_EXCEPTION;
7142 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7148 Py_DECREF_IMMORTAL(result);
7152 Py_LeaveRecursiveCall();
7158 bool r = operand1 == operand2;
7159 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7164 bool r = operand1 != operand2;
7165 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7170#if PYTHON_VERSION < 0x300
7171 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < long()", type1->tp_name);
7172#elif PYTHON_VERSION < 0x360
7173 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < int()", type1->tp_name);
7175 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'int'", type1->tp_name);
7177 return NUITKA_BOOL_EXCEPTION;
7183nuitka_bool RICH_COMPARE_LT_NBOOL_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
7185 if (&PyLong_Type == Py_TYPE(operand2)) {
7186 return COMPARE_LT_CBOOL_LONG_LONG(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7189#if PYTHON_VERSION < 0x300
7190 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7191 return NUITKA_BOOL_EXCEPTION;
7194 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7195 return NUITKA_BOOL_EXCEPTION;
7199 PyTypeObject *type2 = Py_TYPE(operand2);
7201#if PYTHON_VERSION < 0x300
7203 if (&PyLong_Type == type2 && !0) {
7205 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7207 if (frich != NULL) {
7208 PyObject *result = (*frich)(operand1, operand2, Py_LT);
7210 if (result != Py_NotImplemented) {
7211 Py_LeaveRecursiveCall();
7213 if (unlikely(result == NULL)) {
7214 return NUITKA_BOOL_EXCEPTION;
7218 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7224 Py_DECREF_IMMORTAL(result);
7228 cmpfunc fcmp = PyLong_Type.tp_compare;
7231 int c = (*fcmp)(operand1, operand2);
7232 c = adjust_tp_compare(c);
7234 Py_LeaveRecursiveCall();
7237 return NUITKA_BOOL_EXCEPTION;
7260 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7264 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7273 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
7274 f = TP_RICHCOMPARE(type2);
7277 PyObject *result = (*f)(operand2, operand1, Py_GT);
7279 if (result != Py_NotImplemented) {
7280 Py_LeaveRecursiveCall();
7282 if (unlikely(result == NULL)) {
7283 return NUITKA_BOOL_EXCEPTION;
7287 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7293 Py_DECREF_IMMORTAL(result);
7297 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7299 PyObject *result = (*f)(operand1, operand2, Py_LT);
7301 if (result != Py_NotImplemented) {
7302 Py_LeaveRecursiveCall();
7304 if (unlikely(result == NULL)) {
7305 return NUITKA_BOOL_EXCEPTION;
7309 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7315 Py_DECREF_IMMORTAL(result);
7318 f = TP_RICHCOMPARE(type2);
7320 PyObject *result = (*f)(operand2, operand1, Py_GT);
7322 if (result != Py_NotImplemented) {
7323 Py_LeaveRecursiveCall();
7325 if (unlikely(result == NULL)) {
7326 return NUITKA_BOOL_EXCEPTION;
7330 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7336 Py_DECREF_IMMORTAL(result);
7342 cmpfunc fcmp = PyLong_Type.tp_compare;
7343 c = (*fcmp)(operand1, operand2);
7344 }
else if (PyInstance_Check(operand2)) {
7345 cmpfunc fcmp = type2->tp_compare;
7346 c = (*fcmp)(operand1, operand2);
7348 c = try_3way_compare(operand1, operand2);
7352 if (&PyLong_Type == type2) {
7353 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7354 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7356 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7357 }
else if (operand1 == Py_None) {
7360 }
else if (operand2 == Py_None) {
7363 }
else if (PyNumber_Check(operand1)) {
7366 if (PyNumber_Check(operand2)) {
7368 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
7369 Py_uintptr_t bb = (Py_uintptr_t)type2;
7371 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7375 }
else if (PyNumber_Check(operand2)) {
7379 int s = strcmp((PYTHON_VERSION < 0x300 ?
"long" :
"int"), type2->tp_name);
7387 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
7388 Py_uintptr_t bb = (Py_uintptr_t)type2;
7390 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7395 Py_LeaveRecursiveCall();
7397 if (unlikely(c <= -2)) {
7398 return NUITKA_BOOL_EXCEPTION;
7423 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7427 bool checked_reverse_op =
false;
7430 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
7431 f = TP_RICHCOMPARE(type2);
7434 checked_reverse_op =
true;
7436 PyObject *result = (*f)(operand2, operand1, Py_GT);
7438 if (result != Py_NotImplemented) {
7439 Py_LeaveRecursiveCall();
7441 if (unlikely(result == NULL)) {
7442 return NUITKA_BOOL_EXCEPTION;
7446 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7452 Py_DECREF_IMMORTAL(result);
7456 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7459 PyObject *result = (*f)(operand1, operand2, Py_LT);
7461 if (result != Py_NotImplemented) {
7462 Py_LeaveRecursiveCall();
7464 if (unlikely(result == NULL)) {
7465 return NUITKA_BOOL_EXCEPTION;
7469 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7475 Py_DECREF_IMMORTAL(result);
7478 if (checked_reverse_op ==
false) {
7479 f = TP_RICHCOMPARE(type2);
7482 PyObject *result = (*f)(operand2, operand1, Py_GT);
7484 if (result != Py_NotImplemented) {
7485 Py_LeaveRecursiveCall();
7487 if (unlikely(result == NULL)) {
7488 return NUITKA_BOOL_EXCEPTION;
7492 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7498 Py_DECREF_IMMORTAL(result);
7502 Py_LeaveRecursiveCall();
7508 bool r = operand1 == operand2;
7509 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7514 bool r = operand1 != operand2;
7515 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7520#if PYTHON_VERSION < 0x300
7521 PyErr_Format(PyExc_TypeError,
"unorderable types: long() < %s()", type2->tp_name);
7522#elif PYTHON_VERSION < 0x360
7523 PyErr_Format(PyExc_TypeError,
"unorderable types: int() < %s()", type2->tp_name);
7525 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'int' and '%s'", type2->tp_name);
7527 return NUITKA_BOOL_EXCEPTION;
7532static PyObject *COMPARE_LT_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
7533 CHECK_OBJECT(operand1);
7534 assert(PyFloat_CheckExact(operand1));
7535 CHECK_OBJECT(operand2);
7536 assert(PyFloat_CheckExact(operand2));
7538 const double a = PyFloat_AS_DOUBLE(operand1);
7539 const double b = PyFloat_AS_DOUBLE(operand2);
7544 PyObject *result = BOOL_FROM(r);
7545 Py_INCREF_IMMORTAL(result);
7549PyObject *RICH_COMPARE_LT_OBJECT_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
7551 if (Py_TYPE(operand1) == &PyFloat_Type) {
7552 return COMPARE_LT_OBJECT_FLOAT_FLOAT(operand1, operand2);
7555#if PYTHON_VERSION < 0x300
7556 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7560 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7565 PyTypeObject *type1 = Py_TYPE(operand1);
7567#if PYTHON_VERSION < 0x300
7569 if (type1 == &PyFloat_Type && !0) {
7571 richcmpfunc frich = PyFloat_Type.tp_richcompare;
7573 if (frich != NULL) {
7574 PyObject *result = (*frich)(operand1, operand2, Py_LT);
7576 if (result != Py_NotImplemented) {
7577 Py_LeaveRecursiveCall();
7582 Py_DECREF_IMMORTAL(result);
7586 cmpfunc fcmp = NULL;
7589 int c = (*fcmp)(operand1, operand2);
7590 c = adjust_tp_compare(c);
7592 Py_LeaveRecursiveCall();
7618 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7622 PyObject *result = BOOL_FROM(r);
7623 Py_INCREF_IMMORTAL(result);
7631 if (type1 != &PyFloat_Type && 0) {
7632 f = PyFloat_Type.tp_richcompare;
7635 PyObject *result = (*f)(operand2, operand1, Py_GT);
7637 if (result != Py_NotImplemented) {
7638 Py_LeaveRecursiveCall();
7643 Py_DECREF_IMMORTAL(result);
7647 f = TP_RICHCOMPARE(type1);
7649 PyObject *result = (*f)(operand1, operand2, Py_LT);
7651 if (result != Py_NotImplemented) {
7652 Py_LeaveRecursiveCall();
7657 Py_DECREF_IMMORTAL(result);
7660 f = PyFloat_Type.tp_richcompare;
7662 PyObject *result = (*f)(operand2, operand1, Py_GT);
7664 if (result != Py_NotImplemented) {
7665 Py_LeaveRecursiveCall();
7670 Py_DECREF_IMMORTAL(result);
7675 if (PyInstance_Check(operand1)) {
7676 cmpfunc fcmp = type1->tp_compare;
7677 c = (*fcmp)(operand1, operand2);
7679 cmpfunc fcmp = NULL;
7680 c = (*fcmp)(operand1, operand2);
7682 c = try_3way_compare(operand1, operand2);
7686 if (type1 == &PyFloat_Type) {
7687 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7688 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7690 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7691 }
else if (operand1 == Py_None) {
7694 }
else if (operand2 == Py_None) {
7697 }
else if (PyNumber_Check(operand1)) {
7700 if (PyNumber_Check(operand2)) {
7702 Py_uintptr_t aa = (Py_uintptr_t)type1;
7703 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
7705 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7709 }
else if (PyNumber_Check(operand2)) {
7713 int s = strcmp(type1->tp_name,
"float");
7721 Py_uintptr_t aa = (Py_uintptr_t)type1;
7722 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
7724 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7729 Py_LeaveRecursiveCall();
7731 if (unlikely(c <= -2)) {
7757 PyObject *result = BOOL_FROM(r);
7758 Py_INCREF_IMMORTAL(result);
7761 bool checked_reverse_op =
false;
7764 if (type1 != &PyFloat_Type && Nuitka_Type_IsSubtype(&PyFloat_Type, type1)) {
7765 f = PyFloat_Type.tp_richcompare;
7768 checked_reverse_op =
true;
7770 PyObject *result = (*f)(operand2, operand1, Py_GT);
7772 if (result != Py_NotImplemented) {
7773 Py_LeaveRecursiveCall();
7778 Py_DECREF_IMMORTAL(result);
7782 f = TP_RICHCOMPARE(type1);
7785 PyObject *result = (*f)(operand1, operand2, Py_LT);
7787 if (result != Py_NotImplemented) {
7788 Py_LeaveRecursiveCall();
7793 Py_DECREF_IMMORTAL(result);
7796 if (checked_reverse_op ==
false) {
7797 f = PyFloat_Type.tp_richcompare;
7800 PyObject *result = (*f)(operand2, operand1, Py_GT);
7802 if (result != Py_NotImplemented) {
7803 Py_LeaveRecursiveCall();
7808 Py_DECREF_IMMORTAL(result);
7812 Py_LeaveRecursiveCall();
7818 bool r = operand1 == operand2;
7819 PyObject *result = BOOL_FROM(r);
7820 Py_INCREF_IMMORTAL(result);
7824 bool r = operand1 != operand2;
7825 PyObject *result = BOOL_FROM(r);
7826 Py_INCREF_IMMORTAL(result);
7830#if PYTHON_VERSION < 0x360
7831 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < float()", type1->tp_name);
7833 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'float'", type1->tp_name);
7841PyObject *RICH_COMPARE_LT_OBJECT_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
7843 if (&PyFloat_Type == Py_TYPE(operand2)) {
7844 return COMPARE_LT_OBJECT_FLOAT_FLOAT(operand1, operand2);
7847#if PYTHON_VERSION < 0x300
7848 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7852 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7857 PyTypeObject *type2 = Py_TYPE(operand2);
7859#if PYTHON_VERSION < 0x300
7861 if (&PyFloat_Type == type2 && !0) {
7863 richcmpfunc frich = PyFloat_Type.tp_richcompare;
7865 if (frich != NULL) {
7866 PyObject *result = (*frich)(operand1, operand2, Py_LT);
7868 if (result != Py_NotImplemented) {
7869 Py_LeaveRecursiveCall();
7874 Py_DECREF_IMMORTAL(result);
7878 cmpfunc fcmp = NULL;
7881 int c = (*fcmp)(operand1, operand2);
7882 c = adjust_tp_compare(c);
7884 Py_LeaveRecursiveCall();
7910 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7914 PyObject *result = BOOL_FROM(r);
7915 Py_INCREF_IMMORTAL(result);
7923 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
7924 f = TP_RICHCOMPARE(type2);
7927 PyObject *result = (*f)(operand2, operand1, Py_GT);
7929 if (result != Py_NotImplemented) {
7930 Py_LeaveRecursiveCall();
7935 Py_DECREF_IMMORTAL(result);
7939 f = PyFloat_Type.tp_richcompare;
7941 PyObject *result = (*f)(operand1, operand2, Py_LT);
7943 if (result != Py_NotImplemented) {
7944 Py_LeaveRecursiveCall();
7949 Py_DECREF_IMMORTAL(result);
7952 f = TP_RICHCOMPARE(type2);
7954 PyObject *result = (*f)(operand2, operand1, Py_GT);
7956 if (result != Py_NotImplemented) {
7957 Py_LeaveRecursiveCall();
7962 Py_DECREF_IMMORTAL(result);
7968 cmpfunc fcmp = NULL;
7969 c = (*fcmp)(operand1, operand2);
7970 }
else if (PyInstance_Check(operand2)) {
7971 cmpfunc fcmp = type2->tp_compare;
7972 c = (*fcmp)(operand1, operand2);
7974 c = try_3way_compare(operand1, operand2);
7978 if (&PyFloat_Type == type2) {
7979 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7980 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7982 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7983 }
else if (operand1 == Py_None) {
7986 }
else if (operand2 == Py_None) {
7989 }
else if (PyNumber_Check(operand1)) {
7992 if (PyNumber_Check(operand2)) {
7994 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
7995 Py_uintptr_t bb = (Py_uintptr_t)type2;
7997 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8001 }
else if (PyNumber_Check(operand2)) {
8005 int s = strcmp(
"float", type2->tp_name);
8013 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8014 Py_uintptr_t bb = (Py_uintptr_t)type2;
8016 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8021 Py_LeaveRecursiveCall();
8023 if (unlikely(c <= -2)) {
8049 PyObject *result = BOOL_FROM(r);
8050 Py_INCREF_IMMORTAL(result);
8053 bool checked_reverse_op =
false;
8056 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8057 f = TP_RICHCOMPARE(type2);
8060 checked_reverse_op =
true;
8062 PyObject *result = (*f)(operand2, operand1, Py_GT);
8064 if (result != Py_NotImplemented) {
8065 Py_LeaveRecursiveCall();
8070 Py_DECREF_IMMORTAL(result);
8074 f = PyFloat_Type.tp_richcompare;
8077 PyObject *result = (*f)(operand1, operand2, Py_LT);
8079 if (result != Py_NotImplemented) {
8080 Py_LeaveRecursiveCall();
8085 Py_DECREF_IMMORTAL(result);
8088 if (checked_reverse_op ==
false) {
8089 f = TP_RICHCOMPARE(type2);
8092 PyObject *result = (*f)(operand2, operand1, Py_GT);
8094 if (result != Py_NotImplemented) {
8095 Py_LeaveRecursiveCall();
8100 Py_DECREF_IMMORTAL(result);
8104 Py_LeaveRecursiveCall();
8110 bool r = operand1 == operand2;
8111 PyObject *result = BOOL_FROM(r);
8112 Py_INCREF_IMMORTAL(result);
8116 bool r = operand1 != operand2;
8117 PyObject *result = BOOL_FROM(r);
8118 Py_INCREF_IMMORTAL(result);
8122#if PYTHON_VERSION < 0x360
8123 PyErr_Format(PyExc_TypeError,
"unorderable types: float() < %s()", type2->tp_name);
8125 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'float' and '%s'", type2->tp_name);
8133PyObject *RICH_COMPARE_LT_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8135 return COMPARE_LT_OBJECT_FLOAT_FLOAT(operand1, operand2);
8138static bool COMPARE_LT_CBOOL_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8139 CHECK_OBJECT(operand1);
8140 assert(PyFloat_CheckExact(operand1));
8141 CHECK_OBJECT(operand2);
8142 assert(PyFloat_CheckExact(operand2));
8144 const double a = PyFloat_AS_DOUBLE(operand1);
8145 const double b = PyFloat_AS_DOUBLE(operand2);
8155bool RICH_COMPARE_LT_CBOOL_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8157 return COMPARE_LT_CBOOL_FLOAT_FLOAT(operand1, operand2);
8161nuitka_bool RICH_COMPARE_LT_NBOOL_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
8163 if (Py_TYPE(operand1) == &PyFloat_Type) {
8164 return COMPARE_LT_CBOOL_FLOAT_FLOAT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8167#if PYTHON_VERSION < 0x300
8168 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8169 return NUITKA_BOOL_EXCEPTION;
8172 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8173 return NUITKA_BOOL_EXCEPTION;
8177 PyTypeObject *type1 = Py_TYPE(operand1);
8179#if PYTHON_VERSION < 0x300
8181 if (type1 == &PyFloat_Type && !0) {
8183 richcmpfunc frich = PyFloat_Type.tp_richcompare;
8185 if (frich != NULL) {
8186 PyObject *result = (*frich)(operand1, operand2, Py_LT);
8188 if (result != Py_NotImplemented) {
8189 Py_LeaveRecursiveCall();
8191 if (unlikely(result == NULL)) {
8192 return NUITKA_BOOL_EXCEPTION;
8196 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8202 Py_DECREF_IMMORTAL(result);
8206 cmpfunc fcmp = NULL;
8209 int c = (*fcmp)(operand1, operand2);
8210 c = adjust_tp_compare(c);
8212 Py_LeaveRecursiveCall();
8215 return NUITKA_BOOL_EXCEPTION;
8238 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8242 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8251 if (type1 != &PyFloat_Type && 0) {
8252 f = PyFloat_Type.tp_richcompare;
8255 PyObject *result = (*f)(operand2, operand1, Py_GT);
8257 if (result != Py_NotImplemented) {
8258 Py_LeaveRecursiveCall();
8260 if (unlikely(result == NULL)) {
8261 return NUITKA_BOOL_EXCEPTION;
8265 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8271 Py_DECREF_IMMORTAL(result);
8275 f = TP_RICHCOMPARE(type1);
8277 PyObject *result = (*f)(operand1, operand2, Py_LT);
8279 if (result != Py_NotImplemented) {
8280 Py_LeaveRecursiveCall();
8282 if (unlikely(result == NULL)) {
8283 return NUITKA_BOOL_EXCEPTION;
8287 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8293 Py_DECREF_IMMORTAL(result);
8296 f = PyFloat_Type.tp_richcompare;
8298 PyObject *result = (*f)(operand2, operand1, Py_GT);
8300 if (result != Py_NotImplemented) {
8301 Py_LeaveRecursiveCall();
8303 if (unlikely(result == NULL)) {
8304 return NUITKA_BOOL_EXCEPTION;
8308 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8314 Py_DECREF_IMMORTAL(result);
8319 if (PyInstance_Check(operand1)) {
8320 cmpfunc fcmp = type1->tp_compare;
8321 c = (*fcmp)(operand1, operand2);
8323 cmpfunc fcmp = NULL;
8324 c = (*fcmp)(operand1, operand2);
8326 c = try_3way_compare(operand1, operand2);
8330 if (type1 == &PyFloat_Type) {
8331 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8332 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8334 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8335 }
else if (operand1 == Py_None) {
8338 }
else if (operand2 == Py_None) {
8341 }
else if (PyNumber_Check(operand1)) {
8344 if (PyNumber_Check(operand2)) {
8346 Py_uintptr_t aa = (Py_uintptr_t)type1;
8347 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
8349 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8353 }
else if (PyNumber_Check(operand2)) {
8357 int s = strcmp(type1->tp_name,
"float");
8365 Py_uintptr_t aa = (Py_uintptr_t)type1;
8366 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
8368 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8373 Py_LeaveRecursiveCall();
8375 if (unlikely(c <= -2)) {
8376 return NUITKA_BOOL_EXCEPTION;
8401 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8405 bool checked_reverse_op =
false;
8408 if (type1 != &PyFloat_Type && Nuitka_Type_IsSubtype(&PyFloat_Type, type1)) {
8409 f = PyFloat_Type.tp_richcompare;
8412 checked_reverse_op =
true;
8414 PyObject *result = (*f)(operand2, operand1, Py_GT);
8416 if (result != Py_NotImplemented) {
8417 Py_LeaveRecursiveCall();
8419 if (unlikely(result == NULL)) {
8420 return NUITKA_BOOL_EXCEPTION;
8424 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8430 Py_DECREF_IMMORTAL(result);
8434 f = TP_RICHCOMPARE(type1);
8437 PyObject *result = (*f)(operand1, operand2, Py_LT);
8439 if (result != Py_NotImplemented) {
8440 Py_LeaveRecursiveCall();
8442 if (unlikely(result == NULL)) {
8443 return NUITKA_BOOL_EXCEPTION;
8447 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8453 Py_DECREF_IMMORTAL(result);
8456 if (checked_reverse_op ==
false) {
8457 f = PyFloat_Type.tp_richcompare;
8460 PyObject *result = (*f)(operand2, operand1, Py_GT);
8462 if (result != Py_NotImplemented) {
8463 Py_LeaveRecursiveCall();
8465 if (unlikely(result == NULL)) {
8466 return NUITKA_BOOL_EXCEPTION;
8470 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8476 Py_DECREF_IMMORTAL(result);
8480 Py_LeaveRecursiveCall();
8486 bool r = operand1 == operand2;
8487 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8492 bool r = operand1 != operand2;
8493 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8498#if PYTHON_VERSION < 0x360
8499 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < float()", type1->tp_name);
8501 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'float'", type1->tp_name);
8503 return NUITKA_BOOL_EXCEPTION;
8509nuitka_bool RICH_COMPARE_LT_NBOOL_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
8511 if (&PyFloat_Type == Py_TYPE(operand2)) {
8512 return COMPARE_LT_CBOOL_FLOAT_FLOAT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8515#if PYTHON_VERSION < 0x300
8516 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8517 return NUITKA_BOOL_EXCEPTION;
8520 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8521 return NUITKA_BOOL_EXCEPTION;
8525 PyTypeObject *type2 = Py_TYPE(operand2);
8527#if PYTHON_VERSION < 0x300
8529 if (&PyFloat_Type == type2 && !0) {
8531 richcmpfunc frich = PyFloat_Type.tp_richcompare;
8533 if (frich != NULL) {
8534 PyObject *result = (*frich)(operand1, operand2, Py_LT);
8536 if (result != Py_NotImplemented) {
8537 Py_LeaveRecursiveCall();
8539 if (unlikely(result == NULL)) {
8540 return NUITKA_BOOL_EXCEPTION;
8544 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8550 Py_DECREF_IMMORTAL(result);
8554 cmpfunc fcmp = NULL;
8557 int c = (*fcmp)(operand1, operand2);
8558 c = adjust_tp_compare(c);
8560 Py_LeaveRecursiveCall();
8563 return NUITKA_BOOL_EXCEPTION;
8586 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8590 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8599 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8600 f = TP_RICHCOMPARE(type2);
8603 PyObject *result = (*f)(operand2, operand1, Py_GT);
8605 if (result != Py_NotImplemented) {
8606 Py_LeaveRecursiveCall();
8608 if (unlikely(result == NULL)) {
8609 return NUITKA_BOOL_EXCEPTION;
8613 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8619 Py_DECREF_IMMORTAL(result);
8623 f = PyFloat_Type.tp_richcompare;
8625 PyObject *result = (*f)(operand1, operand2, Py_LT);
8627 if (result != Py_NotImplemented) {
8628 Py_LeaveRecursiveCall();
8630 if (unlikely(result == NULL)) {
8631 return NUITKA_BOOL_EXCEPTION;
8635 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8641 Py_DECREF_IMMORTAL(result);
8644 f = TP_RICHCOMPARE(type2);
8646 PyObject *result = (*f)(operand2, operand1, Py_GT);
8648 if (result != Py_NotImplemented) {
8649 Py_LeaveRecursiveCall();
8651 if (unlikely(result == NULL)) {
8652 return NUITKA_BOOL_EXCEPTION;
8656 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8662 Py_DECREF_IMMORTAL(result);
8668 cmpfunc fcmp = NULL;
8669 c = (*fcmp)(operand1, operand2);
8670 }
else if (PyInstance_Check(operand2)) {
8671 cmpfunc fcmp = type2->tp_compare;
8672 c = (*fcmp)(operand1, operand2);
8674 c = try_3way_compare(operand1, operand2);
8678 if (&PyFloat_Type == type2) {
8679 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8680 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8682 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8683 }
else if (operand1 == Py_None) {
8686 }
else if (operand2 == Py_None) {
8689 }
else if (PyNumber_Check(operand1)) {
8692 if (PyNumber_Check(operand2)) {
8694 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8695 Py_uintptr_t bb = (Py_uintptr_t)type2;
8697 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8701 }
else if (PyNumber_Check(operand2)) {
8705 int s = strcmp(
"float", type2->tp_name);
8713 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8714 Py_uintptr_t bb = (Py_uintptr_t)type2;
8716 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8721 Py_LeaveRecursiveCall();
8723 if (unlikely(c <= -2)) {
8724 return NUITKA_BOOL_EXCEPTION;
8749 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8753 bool checked_reverse_op =
false;
8756 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8757 f = TP_RICHCOMPARE(type2);
8760 checked_reverse_op =
true;
8762 PyObject *result = (*f)(operand2, operand1, Py_GT);
8764 if (result != Py_NotImplemented) {
8765 Py_LeaveRecursiveCall();
8767 if (unlikely(result == NULL)) {
8768 return NUITKA_BOOL_EXCEPTION;
8772 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8778 Py_DECREF_IMMORTAL(result);
8782 f = PyFloat_Type.tp_richcompare;
8785 PyObject *result = (*f)(operand1, operand2, Py_LT);
8787 if (result != Py_NotImplemented) {
8788 Py_LeaveRecursiveCall();
8790 if (unlikely(result == NULL)) {
8791 return NUITKA_BOOL_EXCEPTION;
8795 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8801 Py_DECREF_IMMORTAL(result);
8804 if (checked_reverse_op ==
false) {
8805 f = TP_RICHCOMPARE(type2);
8808 PyObject *result = (*f)(operand2, operand1, Py_GT);
8810 if (result != Py_NotImplemented) {
8811 Py_LeaveRecursiveCall();
8813 if (unlikely(result == NULL)) {
8814 return NUITKA_BOOL_EXCEPTION;
8818 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8824 Py_DECREF_IMMORTAL(result);
8828 Py_LeaveRecursiveCall();
8834 bool r = operand1 == operand2;
8835 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8840 bool r = operand1 != operand2;
8841 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8846#if PYTHON_VERSION < 0x360
8847 PyErr_Format(PyExc_TypeError,
"unorderable types: float() < %s()", type2->tp_name);
8849 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'float' and '%s'", type2->tp_name);
8851 return NUITKA_BOOL_EXCEPTION;
8856static PyObject *COMPARE_LT_OBJECT_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
8857 CHECK_OBJECT(operand1);
8858 assert(PyTuple_CheckExact(operand1));
8859 CHECK_OBJECT(operand2);
8860 assert(PyTuple_CheckExact(operand2));
8862 PyTupleObject *a = (PyTupleObject *)operand1;
8863 PyTupleObject *b = (PyTupleObject *)operand2;
8865 Py_ssize_t len_a = Py_SIZE(a);
8866 Py_ssize_t len_b = Py_SIZE(b);
8869 nuitka_bool res = NUITKA_BOOL_TRUE;
8872 for (i = 0; i < len_a && i < len_b; i++) {
8873 PyObject *aa = a->ob_item[i];
8874 PyObject *bb = b->ob_item[i];
8880 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
8882 if (res == NUITKA_BOOL_EXCEPTION) {
8886 if (res == NUITKA_BOOL_FALSE) {
8892 if (found ==
false) {
8893 bool r = len_a < len_b;
8896 PyObject *result = BOOL_FROM(r);
8897 Py_INCREF_IMMORTAL(result);
8901 return RICH_COMPARE_LT_OBJECT_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
8904PyObject *RICH_COMPARE_LT_OBJECT_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
8906 if (Py_TYPE(operand1) == &PyTuple_Type) {
8907 return COMPARE_LT_OBJECT_TUPLE_TUPLE(operand1, operand2);
8910#if PYTHON_VERSION < 0x300
8911 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8915 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8920 PyTypeObject *type1 = Py_TYPE(operand1);
8922#if PYTHON_VERSION < 0x300
8924 if (type1 == &PyTuple_Type && !0) {
8926 richcmpfunc frich = PyTuple_Type.tp_richcompare;
8928 if (frich != NULL) {
8929 PyObject *result = (*frich)(operand1, operand2, Py_LT);
8931 if (result != Py_NotImplemented) {
8932 Py_LeaveRecursiveCall();
8937 Py_DECREF_IMMORTAL(result);
8941 cmpfunc fcmp = NULL;
8944 int c = (*fcmp)(operand1, operand2);
8945 c = adjust_tp_compare(c);
8947 Py_LeaveRecursiveCall();
8973 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8977 PyObject *result = BOOL_FROM(r);
8978 Py_INCREF_IMMORTAL(result);
8986 if (type1 != &PyTuple_Type && 0) {
8987 f = PyTuple_Type.tp_richcompare;
8990 PyObject *result = (*f)(operand2, operand1, Py_GT);
8992 if (result != Py_NotImplemented) {
8993 Py_LeaveRecursiveCall();
8998 Py_DECREF_IMMORTAL(result);
9002 f = TP_RICHCOMPARE(type1);
9004 PyObject *result = (*f)(operand1, operand2, Py_LT);
9006 if (result != Py_NotImplemented) {
9007 Py_LeaveRecursiveCall();
9012 Py_DECREF_IMMORTAL(result);
9015 f = PyTuple_Type.tp_richcompare;
9017 PyObject *result = (*f)(operand2, operand1, Py_GT);
9019 if (result != Py_NotImplemented) {
9020 Py_LeaveRecursiveCall();
9025 Py_DECREF_IMMORTAL(result);
9030 if (PyInstance_Check(operand1)) {
9031 cmpfunc fcmp = type1->tp_compare;
9032 c = (*fcmp)(operand1, operand2);
9034 cmpfunc fcmp = NULL;
9035 c = (*fcmp)(operand1, operand2);
9037 c = try_3way_compare(operand1, operand2);
9041 if (type1 == &PyTuple_Type) {
9042 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9043 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9045 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9046 }
else if (operand1 == Py_None) {
9049 }
else if (operand2 == Py_None) {
9052 }
else if (PyNumber_Check(operand1)) {
9055 if (PyNumber_Check(operand2)) {
9057 Py_uintptr_t aa = (Py_uintptr_t)type1;
9058 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9060 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9064 }
else if (PyNumber_Check(operand2)) {
9068 int s = strcmp(type1->tp_name,
"tuple");
9076 Py_uintptr_t aa = (Py_uintptr_t)type1;
9077 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9079 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9084 Py_LeaveRecursiveCall();
9086 if (unlikely(c <= -2)) {
9112 PyObject *result = BOOL_FROM(r);
9113 Py_INCREF_IMMORTAL(result);
9116 bool checked_reverse_op =
false;
9119 if (type1 != &PyTuple_Type && Nuitka_Type_IsSubtype(&PyTuple_Type, type1)) {
9120 f = PyTuple_Type.tp_richcompare;
9123 checked_reverse_op =
true;
9125 PyObject *result = (*f)(operand2, operand1, Py_GT);
9127 if (result != Py_NotImplemented) {
9128 Py_LeaveRecursiveCall();
9133 Py_DECREF_IMMORTAL(result);
9137 f = TP_RICHCOMPARE(type1);
9140 PyObject *result = (*f)(operand1, operand2, Py_LT);
9142 if (result != Py_NotImplemented) {
9143 Py_LeaveRecursiveCall();
9148 Py_DECREF_IMMORTAL(result);
9151 if (checked_reverse_op ==
false) {
9152 f = PyTuple_Type.tp_richcompare;
9155 PyObject *result = (*f)(operand2, operand1, Py_GT);
9157 if (result != Py_NotImplemented) {
9158 Py_LeaveRecursiveCall();
9163 Py_DECREF_IMMORTAL(result);
9167 Py_LeaveRecursiveCall();
9173 bool r = operand1 == operand2;
9174 PyObject *result = BOOL_FROM(r);
9175 Py_INCREF_IMMORTAL(result);
9179 bool r = operand1 != operand2;
9180 PyObject *result = BOOL_FROM(r);
9181 Py_INCREF_IMMORTAL(result);
9185#if PYTHON_VERSION < 0x360
9186 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < tuple()", type1->tp_name);
9188 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'tuple'", type1->tp_name);
9196PyObject *RICH_COMPARE_LT_OBJECT_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
9198 if (&PyTuple_Type == Py_TYPE(operand2)) {
9199 return COMPARE_LT_OBJECT_TUPLE_TUPLE(operand1, operand2);
9202#if PYTHON_VERSION < 0x300
9203 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9207 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9212 PyTypeObject *type2 = Py_TYPE(operand2);
9214#if PYTHON_VERSION < 0x300
9216 if (&PyTuple_Type == type2 && !0) {
9218 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9220 if (frich != NULL) {
9221 PyObject *result = (*frich)(operand1, operand2, Py_LT);
9223 if (result != Py_NotImplemented) {
9224 Py_LeaveRecursiveCall();
9229 Py_DECREF_IMMORTAL(result);
9233 cmpfunc fcmp = NULL;
9236 int c = (*fcmp)(operand1, operand2);
9237 c = adjust_tp_compare(c);
9239 Py_LeaveRecursiveCall();
9265 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9269 PyObject *result = BOOL_FROM(r);
9270 Py_INCREF_IMMORTAL(result);
9278 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9279 f = TP_RICHCOMPARE(type2);
9282 PyObject *result = (*f)(operand2, operand1, Py_GT);
9284 if (result != Py_NotImplemented) {
9285 Py_LeaveRecursiveCall();
9290 Py_DECREF_IMMORTAL(result);
9294 f = PyTuple_Type.tp_richcompare;
9296 PyObject *result = (*f)(operand1, operand2, Py_LT);
9298 if (result != Py_NotImplemented) {
9299 Py_LeaveRecursiveCall();
9304 Py_DECREF_IMMORTAL(result);
9307 f = TP_RICHCOMPARE(type2);
9309 PyObject *result = (*f)(operand2, operand1, Py_GT);
9311 if (result != Py_NotImplemented) {
9312 Py_LeaveRecursiveCall();
9317 Py_DECREF_IMMORTAL(result);
9323 cmpfunc fcmp = NULL;
9324 c = (*fcmp)(operand1, operand2);
9325 }
else if (PyInstance_Check(operand2)) {
9326 cmpfunc fcmp = type2->tp_compare;
9327 c = (*fcmp)(operand1, operand2);
9329 c = try_3way_compare(operand1, operand2);
9333 if (&PyTuple_Type == type2) {
9334 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9335 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9337 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9338 }
else if (operand1 == Py_None) {
9341 }
else if (operand2 == Py_None) {
9344 }
else if (PyNumber_Check(operand1)) {
9347 if (PyNumber_Check(operand2)) {
9349 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
9350 Py_uintptr_t bb = (Py_uintptr_t)type2;
9352 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9356 }
else if (PyNumber_Check(operand2)) {
9360 int s = strcmp(
"tuple", type2->tp_name);
9368 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
9369 Py_uintptr_t bb = (Py_uintptr_t)type2;
9371 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9376 Py_LeaveRecursiveCall();
9378 if (unlikely(c <= -2)) {
9404 PyObject *result = BOOL_FROM(r);
9405 Py_INCREF_IMMORTAL(result);
9408 bool checked_reverse_op =
false;
9411 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9412 f = TP_RICHCOMPARE(type2);
9415 checked_reverse_op =
true;
9417 PyObject *result = (*f)(operand2, operand1, Py_GT);
9419 if (result != Py_NotImplemented) {
9420 Py_LeaveRecursiveCall();
9425 Py_DECREF_IMMORTAL(result);
9429 f = PyTuple_Type.tp_richcompare;
9432 PyObject *result = (*f)(operand1, operand2, Py_LT);
9434 if (result != Py_NotImplemented) {
9435 Py_LeaveRecursiveCall();
9440 Py_DECREF_IMMORTAL(result);
9443 if (checked_reverse_op ==
false) {
9444 f = TP_RICHCOMPARE(type2);
9447 PyObject *result = (*f)(operand2, operand1, Py_GT);
9449 if (result != Py_NotImplemented) {
9450 Py_LeaveRecursiveCall();
9455 Py_DECREF_IMMORTAL(result);
9459 Py_LeaveRecursiveCall();
9465 bool r = operand1 == operand2;
9466 PyObject *result = BOOL_FROM(r);
9467 Py_INCREF_IMMORTAL(result);
9471 bool r = operand1 != operand2;
9472 PyObject *result = BOOL_FROM(r);
9473 Py_INCREF_IMMORTAL(result);
9477#if PYTHON_VERSION < 0x360
9478 PyErr_Format(PyExc_TypeError,
"unorderable types: tuple() < %s()", type2->tp_name);
9480 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'tuple' and '%s'", type2->tp_name);
9488PyObject *RICH_COMPARE_LT_OBJECT_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
9490 return COMPARE_LT_OBJECT_TUPLE_TUPLE(operand1, operand2);
9493static nuitka_bool COMPARE_LT_NBOOL_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
9494 CHECK_OBJECT(operand1);
9495 assert(PyTuple_CheckExact(operand1));
9496 CHECK_OBJECT(operand2);
9497 assert(PyTuple_CheckExact(operand2));
9499 PyTupleObject *a = (PyTupleObject *)operand1;
9500 PyTupleObject *b = (PyTupleObject *)operand2;
9502 Py_ssize_t len_a = Py_SIZE(a);
9503 Py_ssize_t len_b = Py_SIZE(b);
9506 nuitka_bool res = NUITKA_BOOL_TRUE;
9509 for (i = 0; i < len_a && i < len_b; i++) {
9510 PyObject *aa = a->ob_item[i];
9511 PyObject *bb = b->ob_item[i];
9517 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
9519 if (res == NUITKA_BOOL_EXCEPTION) {
9520 return NUITKA_BOOL_EXCEPTION;
9523 if (res == NUITKA_BOOL_FALSE) {
9529 if (found ==
false) {
9530 bool r = len_a < len_b;
9533 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9538 return RICH_COMPARE_LT_NBOOL_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
9541nuitka_bool RICH_COMPARE_LT_NBOOL_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
9543 if (Py_TYPE(operand1) == &PyTuple_Type) {
9544 return COMPARE_LT_NBOOL_TUPLE_TUPLE(operand1, operand2);
9547#if PYTHON_VERSION < 0x300
9548 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9549 return NUITKA_BOOL_EXCEPTION;
9552 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9553 return NUITKA_BOOL_EXCEPTION;
9557 PyTypeObject *type1 = Py_TYPE(operand1);
9559#if PYTHON_VERSION < 0x300
9561 if (type1 == &PyTuple_Type && !0) {
9563 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9565 if (frich != NULL) {
9566 PyObject *result = (*frich)(operand1, operand2, Py_LT);
9568 if (result != Py_NotImplemented) {
9569 Py_LeaveRecursiveCall();
9571 if (unlikely(result == NULL)) {
9572 return NUITKA_BOOL_EXCEPTION;
9576 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9582 Py_DECREF_IMMORTAL(result);
9586 cmpfunc fcmp = NULL;
9589 int c = (*fcmp)(operand1, operand2);
9590 c = adjust_tp_compare(c);
9592 Py_LeaveRecursiveCall();
9595 return NUITKA_BOOL_EXCEPTION;
9618 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9622 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9631 if (type1 != &PyTuple_Type && 0) {
9632 f = PyTuple_Type.tp_richcompare;
9635 PyObject *result = (*f)(operand2, operand1, Py_GT);
9637 if (result != Py_NotImplemented) {
9638 Py_LeaveRecursiveCall();
9640 if (unlikely(result == NULL)) {
9641 return NUITKA_BOOL_EXCEPTION;
9645 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9651 Py_DECREF_IMMORTAL(result);
9655 f = TP_RICHCOMPARE(type1);
9657 PyObject *result = (*f)(operand1, operand2, Py_LT);
9659 if (result != Py_NotImplemented) {
9660 Py_LeaveRecursiveCall();
9662 if (unlikely(result == NULL)) {
9663 return NUITKA_BOOL_EXCEPTION;
9667 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9673 Py_DECREF_IMMORTAL(result);
9676 f = PyTuple_Type.tp_richcompare;
9678 PyObject *result = (*f)(operand2, operand1, Py_GT);
9680 if (result != Py_NotImplemented) {
9681 Py_LeaveRecursiveCall();
9683 if (unlikely(result == NULL)) {
9684 return NUITKA_BOOL_EXCEPTION;
9688 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9694 Py_DECREF_IMMORTAL(result);
9699 if (PyInstance_Check(operand1)) {
9700 cmpfunc fcmp = type1->tp_compare;
9701 c = (*fcmp)(operand1, operand2);
9703 cmpfunc fcmp = NULL;
9704 c = (*fcmp)(operand1, operand2);
9706 c = try_3way_compare(operand1, operand2);
9710 if (type1 == &PyTuple_Type) {
9711 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9712 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9714 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9715 }
else if (operand1 == Py_None) {
9718 }
else if (operand2 == Py_None) {
9721 }
else if (PyNumber_Check(operand1)) {
9724 if (PyNumber_Check(operand2)) {
9726 Py_uintptr_t aa = (Py_uintptr_t)type1;
9727 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9729 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9733 }
else if (PyNumber_Check(operand2)) {
9737 int s = strcmp(type1->tp_name,
"tuple");
9745 Py_uintptr_t aa = (Py_uintptr_t)type1;
9746 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9748 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9753 Py_LeaveRecursiveCall();
9755 if (unlikely(c <= -2)) {
9756 return NUITKA_BOOL_EXCEPTION;
9781 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9785 bool checked_reverse_op =
false;
9788 if (type1 != &PyTuple_Type && Nuitka_Type_IsSubtype(&PyTuple_Type, type1)) {
9789 f = PyTuple_Type.tp_richcompare;
9792 checked_reverse_op =
true;
9794 PyObject *result = (*f)(operand2, operand1, Py_GT);
9796 if (result != Py_NotImplemented) {
9797 Py_LeaveRecursiveCall();
9799 if (unlikely(result == NULL)) {
9800 return NUITKA_BOOL_EXCEPTION;
9804 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9810 Py_DECREF_IMMORTAL(result);
9814 f = TP_RICHCOMPARE(type1);
9817 PyObject *result = (*f)(operand1, operand2, Py_LT);
9819 if (result != Py_NotImplemented) {
9820 Py_LeaveRecursiveCall();
9822 if (unlikely(result == NULL)) {
9823 return NUITKA_BOOL_EXCEPTION;
9827 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9833 Py_DECREF_IMMORTAL(result);
9836 if (checked_reverse_op ==
false) {
9837 f = PyTuple_Type.tp_richcompare;
9840 PyObject *result = (*f)(operand2, operand1, Py_GT);
9842 if (result != Py_NotImplemented) {
9843 Py_LeaveRecursiveCall();
9845 if (unlikely(result == NULL)) {
9846 return NUITKA_BOOL_EXCEPTION;
9850 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9856 Py_DECREF_IMMORTAL(result);
9860 Py_LeaveRecursiveCall();
9866 bool r = operand1 == operand2;
9867 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9872 bool r = operand1 != operand2;
9873 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9878#if PYTHON_VERSION < 0x360
9879 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < tuple()", type1->tp_name);
9881 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'tuple'", type1->tp_name);
9883 return NUITKA_BOOL_EXCEPTION;
9889nuitka_bool RICH_COMPARE_LT_NBOOL_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
9891 if (&PyTuple_Type == Py_TYPE(operand2)) {
9892 return COMPARE_LT_NBOOL_TUPLE_TUPLE(operand1, operand2);
9895#if PYTHON_VERSION < 0x300
9896 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9897 return NUITKA_BOOL_EXCEPTION;
9900 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9901 return NUITKA_BOOL_EXCEPTION;
9905 PyTypeObject *type2 = Py_TYPE(operand2);
9907#if PYTHON_VERSION < 0x300
9909 if (&PyTuple_Type == type2 && !0) {
9911 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9913 if (frich != NULL) {
9914 PyObject *result = (*frich)(operand1, operand2, Py_LT);
9916 if (result != Py_NotImplemented) {
9917 Py_LeaveRecursiveCall();
9919 if (unlikely(result == NULL)) {
9920 return NUITKA_BOOL_EXCEPTION;
9924 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9930 Py_DECREF_IMMORTAL(result);
9934 cmpfunc fcmp = NULL;
9937 int c = (*fcmp)(operand1, operand2);
9938 c = adjust_tp_compare(c);
9940 Py_LeaveRecursiveCall();
9943 return NUITKA_BOOL_EXCEPTION;
9966 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9970 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9979 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9980 f = TP_RICHCOMPARE(type2);
9983 PyObject *result = (*f)(operand2, operand1, Py_GT);
9985 if (result != Py_NotImplemented) {
9986 Py_LeaveRecursiveCall();
9988 if (unlikely(result == NULL)) {
9989 return NUITKA_BOOL_EXCEPTION;
9993 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9999 Py_DECREF_IMMORTAL(result);
10003 f = PyTuple_Type.tp_richcompare;
10005 PyObject *result = (*f)(operand1, operand2, Py_LT);
10007 if (result != Py_NotImplemented) {
10008 Py_LeaveRecursiveCall();
10010 if (unlikely(result == NULL)) {
10011 return NUITKA_BOOL_EXCEPTION;
10015 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10021 Py_DECREF_IMMORTAL(result);
10024 f = TP_RICHCOMPARE(type2);
10026 PyObject *result = (*f)(operand2, operand1, Py_GT);
10028 if (result != Py_NotImplemented) {
10029 Py_LeaveRecursiveCall();
10031 if (unlikely(result == NULL)) {
10032 return NUITKA_BOOL_EXCEPTION;
10036 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10042 Py_DECREF_IMMORTAL(result);
10048 cmpfunc fcmp = NULL;
10049 c = (*fcmp)(operand1, operand2);
10050 }
else if (PyInstance_Check(operand2)) {
10051 cmpfunc fcmp = type2->tp_compare;
10052 c = (*fcmp)(operand1, operand2);
10054 c = try_3way_compare(operand1, operand2);
10058 if (&PyTuple_Type == type2) {
10059 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10060 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10062 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10063 }
else if (operand1 == Py_None) {
10066 }
else if (operand2 == Py_None) {
10069 }
else if (PyNumber_Check(operand1)) {
10072 if (PyNumber_Check(operand2)) {
10074 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
10075 Py_uintptr_t bb = (Py_uintptr_t)type2;
10077 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10081 }
else if (PyNumber_Check(operand2)) {
10085 int s = strcmp(
"tuple", type2->tp_name);
10089 }
else if (s > 0) {
10093 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
10094 Py_uintptr_t bb = (Py_uintptr_t)type2;
10096 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10101 Py_LeaveRecursiveCall();
10103 if (unlikely(c <= -2)) {
10104 return NUITKA_BOOL_EXCEPTION;
10129 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10133 bool checked_reverse_op =
false;
10136 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
10137 f = TP_RICHCOMPARE(type2);
10140 checked_reverse_op =
true;
10142 PyObject *result = (*f)(operand2, operand1, Py_GT);
10144 if (result != Py_NotImplemented) {
10145 Py_LeaveRecursiveCall();
10147 if (unlikely(result == NULL)) {
10148 return NUITKA_BOOL_EXCEPTION;
10152 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10158 Py_DECREF_IMMORTAL(result);
10162 f = PyTuple_Type.tp_richcompare;
10165 PyObject *result = (*f)(operand1, operand2, Py_LT);
10167 if (result != Py_NotImplemented) {
10168 Py_LeaveRecursiveCall();
10170 if (unlikely(result == NULL)) {
10171 return NUITKA_BOOL_EXCEPTION;
10175 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10181 Py_DECREF_IMMORTAL(result);
10184 if (checked_reverse_op ==
false) {
10185 f = TP_RICHCOMPARE(type2);
10188 PyObject *result = (*f)(operand2, operand1, Py_GT);
10190 if (result != Py_NotImplemented) {
10191 Py_LeaveRecursiveCall();
10193 if (unlikely(result == NULL)) {
10194 return NUITKA_BOOL_EXCEPTION;
10198 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10204 Py_DECREF_IMMORTAL(result);
10208 Py_LeaveRecursiveCall();
10214 bool r = operand1 == operand2;
10215 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10220 bool r = operand1 != operand2;
10221 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10226#if PYTHON_VERSION < 0x360
10227 PyErr_Format(PyExc_TypeError,
"unorderable types: tuple() < %s()", type2->tp_name);
10229 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'tuple' and '%s'", type2->tp_name);
10231 return NUITKA_BOOL_EXCEPTION;
10237nuitka_bool RICH_COMPARE_LT_NBOOL_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
10239 return COMPARE_LT_NBOOL_TUPLE_TUPLE(operand1, operand2);
10242static PyObject *COMPARE_LT_OBJECT_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10243 CHECK_OBJECT(operand1);
10244 assert(PyList_CheckExact(operand1));
10245 CHECK_OBJECT(operand2);
10246 assert(PyList_CheckExact(operand2));
10248 PyListObject *a = (PyListObject *)operand1;
10249 PyListObject *b = (PyListObject *)operand2;
10251 bool found =
false;
10252 nuitka_bool res = NUITKA_BOOL_TRUE;
10255 for (i = 0; i < Py_SIZE(a) && i < Py_SIZE(b); i++) {
10256 PyObject *aa = a->ob_item[i];
10257 PyObject *bb = b->ob_item[i];
10265 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
10269 if (res == NUITKA_BOOL_EXCEPTION) {
10273 if (res == NUITKA_BOOL_FALSE) {
10279 if (found ==
false) {
10280 bool r = Py_SIZE(a) < Py_SIZE(b);
10283 PyObject *result = BOOL_FROM(r);
10284 Py_INCREF_IMMORTAL(result);
10288 return RICH_COMPARE_LT_OBJECT_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
10291PyObject *RICH_COMPARE_LT_OBJECT_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
10293 if (Py_TYPE(operand1) == &PyList_Type) {
10294 return COMPARE_LT_OBJECT_LIST_LIST(operand1, operand2);
10297#if PYTHON_VERSION < 0x300
10298 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10302 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10307 PyTypeObject *type1 = Py_TYPE(operand1);
10309#if PYTHON_VERSION < 0x300
10311 if (type1 == &PyList_Type && !0) {
10313 richcmpfunc frich = PyList_Type.tp_richcompare;
10315 if (frich != NULL) {
10316 PyObject *result = (*frich)(operand1, operand2, Py_LT);
10318 if (result != Py_NotImplemented) {
10319 Py_LeaveRecursiveCall();
10324 Py_DECREF_IMMORTAL(result);
10328 cmpfunc fcmp = NULL;
10330 if (fcmp != NULL) {
10331 int c = (*fcmp)(operand1, operand2);
10332 c = adjust_tp_compare(c);
10334 Py_LeaveRecursiveCall();
10360 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10364 PyObject *result = BOOL_FROM(r);
10365 Py_INCREF_IMMORTAL(result);
10373 if (type1 != &PyList_Type && 0) {
10374 f = PyList_Type.tp_richcompare;
10377 PyObject *result = (*f)(operand2, operand1, Py_GT);
10379 if (result != Py_NotImplemented) {
10380 Py_LeaveRecursiveCall();
10385 Py_DECREF_IMMORTAL(result);
10389 f = TP_RICHCOMPARE(type1);
10391 PyObject *result = (*f)(operand1, operand2, Py_LT);
10393 if (result != Py_NotImplemented) {
10394 Py_LeaveRecursiveCall();
10399 Py_DECREF_IMMORTAL(result);
10402 f = PyList_Type.tp_richcompare;
10404 PyObject *result = (*f)(operand2, operand1, Py_GT);
10406 if (result != Py_NotImplemented) {
10407 Py_LeaveRecursiveCall();
10412 Py_DECREF_IMMORTAL(result);
10417 if (PyInstance_Check(operand1)) {
10418 cmpfunc fcmp = type1->tp_compare;
10419 c = (*fcmp)(operand1, operand2);
10421 cmpfunc fcmp = NULL;
10422 c = (*fcmp)(operand1, operand2);
10424 c = try_3way_compare(operand1, operand2);
10428 if (type1 == &PyList_Type) {
10429 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10430 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10432 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10433 }
else if (operand1 == Py_None) {
10436 }
else if (operand2 == Py_None) {
10439 }
else if (PyNumber_Check(operand1)) {
10442 if (PyNumber_Check(operand2)) {
10444 Py_uintptr_t aa = (Py_uintptr_t)type1;
10445 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
10447 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10451 }
else if (PyNumber_Check(operand2)) {
10455 int s = strcmp(type1->tp_name,
"list");
10459 }
else if (s > 0) {
10463 Py_uintptr_t aa = (Py_uintptr_t)type1;
10464 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
10466 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10471 Py_LeaveRecursiveCall();
10473 if (unlikely(c <= -2)) {
10499 PyObject *result = BOOL_FROM(r);
10500 Py_INCREF_IMMORTAL(result);
10503 bool checked_reverse_op =
false;
10506 if (type1 != &PyList_Type && Nuitka_Type_IsSubtype(&PyList_Type, type1)) {
10507 f = PyList_Type.tp_richcompare;
10510 checked_reverse_op =
true;
10512 PyObject *result = (*f)(operand2, operand1, Py_GT);
10514 if (result != Py_NotImplemented) {
10515 Py_LeaveRecursiveCall();
10520 Py_DECREF_IMMORTAL(result);
10524 f = TP_RICHCOMPARE(type1);
10527 PyObject *result = (*f)(operand1, operand2, Py_LT);
10529 if (result != Py_NotImplemented) {
10530 Py_LeaveRecursiveCall();
10535 Py_DECREF_IMMORTAL(result);
10538 if (checked_reverse_op ==
false) {
10539 f = PyList_Type.tp_richcompare;
10542 PyObject *result = (*f)(operand2, operand1, Py_GT);
10544 if (result != Py_NotImplemented) {
10545 Py_LeaveRecursiveCall();
10550 Py_DECREF_IMMORTAL(result);
10554 Py_LeaveRecursiveCall();
10560 bool r = operand1 == operand2;
10561 PyObject *result = BOOL_FROM(r);
10562 Py_INCREF_IMMORTAL(result);
10566 bool r = operand1 != operand2;
10567 PyObject *result = BOOL_FROM(r);
10568 Py_INCREF_IMMORTAL(result);
10572#if PYTHON_VERSION < 0x360
10573 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < list()", type1->tp_name);
10575 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'list'", type1->tp_name);
10583PyObject *RICH_COMPARE_LT_OBJECT_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
10585 if (&PyList_Type == Py_TYPE(operand2)) {
10586 return COMPARE_LT_OBJECT_LIST_LIST(operand1, operand2);
10589#if PYTHON_VERSION < 0x300
10590 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10594 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10599 PyTypeObject *type2 = Py_TYPE(operand2);
10601#if PYTHON_VERSION < 0x300
10603 if (&PyList_Type == type2 && !0) {
10605 richcmpfunc frich = PyList_Type.tp_richcompare;
10607 if (frich != NULL) {
10608 PyObject *result = (*frich)(operand1, operand2, Py_LT);
10610 if (result != Py_NotImplemented) {
10611 Py_LeaveRecursiveCall();
10616 Py_DECREF_IMMORTAL(result);
10620 cmpfunc fcmp = NULL;
10622 if (fcmp != NULL) {
10623 int c = (*fcmp)(operand1, operand2);
10624 c = adjust_tp_compare(c);
10626 Py_LeaveRecursiveCall();
10652 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10656 PyObject *result = BOOL_FROM(r);
10657 Py_INCREF_IMMORTAL(result);
10665 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
10666 f = TP_RICHCOMPARE(type2);
10669 PyObject *result = (*f)(operand2, operand1, Py_GT);
10671 if (result != Py_NotImplemented) {
10672 Py_LeaveRecursiveCall();
10677 Py_DECREF_IMMORTAL(result);
10681 f = PyList_Type.tp_richcompare;
10683 PyObject *result = (*f)(operand1, operand2, Py_LT);
10685 if (result != Py_NotImplemented) {
10686 Py_LeaveRecursiveCall();
10691 Py_DECREF_IMMORTAL(result);
10694 f = TP_RICHCOMPARE(type2);
10696 PyObject *result = (*f)(operand2, operand1, Py_GT);
10698 if (result != Py_NotImplemented) {
10699 Py_LeaveRecursiveCall();
10704 Py_DECREF_IMMORTAL(result);
10710 cmpfunc fcmp = NULL;
10711 c = (*fcmp)(operand1, operand2);
10712 }
else if (PyInstance_Check(operand2)) {
10713 cmpfunc fcmp = type2->tp_compare;
10714 c = (*fcmp)(operand1, operand2);
10716 c = try_3way_compare(operand1, operand2);
10720 if (&PyList_Type == type2) {
10721 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10722 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10724 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10725 }
else if (operand1 == Py_None) {
10728 }
else if (operand2 == Py_None) {
10731 }
else if (PyNumber_Check(operand1)) {
10734 if (PyNumber_Check(operand2)) {
10736 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
10737 Py_uintptr_t bb = (Py_uintptr_t)type2;
10739 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10743 }
else if (PyNumber_Check(operand2)) {
10747 int s = strcmp(
"list", type2->tp_name);
10751 }
else if (s > 0) {
10755 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
10756 Py_uintptr_t bb = (Py_uintptr_t)type2;
10758 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10763 Py_LeaveRecursiveCall();
10765 if (unlikely(c <= -2)) {
10791 PyObject *result = BOOL_FROM(r);
10792 Py_INCREF_IMMORTAL(result);
10795 bool checked_reverse_op =
false;
10798 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
10799 f = TP_RICHCOMPARE(type2);
10802 checked_reverse_op =
true;
10804 PyObject *result = (*f)(operand2, operand1, Py_GT);
10806 if (result != Py_NotImplemented) {
10807 Py_LeaveRecursiveCall();
10812 Py_DECREF_IMMORTAL(result);
10816 f = PyList_Type.tp_richcompare;
10819 PyObject *result = (*f)(operand1, operand2, Py_LT);
10821 if (result != Py_NotImplemented) {
10822 Py_LeaveRecursiveCall();
10827 Py_DECREF_IMMORTAL(result);
10830 if (checked_reverse_op ==
false) {
10831 f = TP_RICHCOMPARE(type2);
10834 PyObject *result = (*f)(operand2, operand1, Py_GT);
10836 if (result != Py_NotImplemented) {
10837 Py_LeaveRecursiveCall();
10842 Py_DECREF_IMMORTAL(result);
10846 Py_LeaveRecursiveCall();
10852 bool r = operand1 == operand2;
10853 PyObject *result = BOOL_FROM(r);
10854 Py_INCREF_IMMORTAL(result);
10858 bool r = operand1 != operand2;
10859 PyObject *result = BOOL_FROM(r);
10860 Py_INCREF_IMMORTAL(result);
10864#if PYTHON_VERSION < 0x360
10865 PyErr_Format(PyExc_TypeError,
"unorderable types: list() < %s()", type2->tp_name);
10867 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'list' and '%s'", type2->tp_name);
10875PyObject *RICH_COMPARE_LT_OBJECT_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10877 return COMPARE_LT_OBJECT_LIST_LIST(operand1, operand2);
10880static nuitka_bool COMPARE_LT_NBOOL_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10881 CHECK_OBJECT(operand1);
10882 assert(PyList_CheckExact(operand1));
10883 CHECK_OBJECT(operand2);
10884 assert(PyList_CheckExact(operand2));
10886 PyListObject *a = (PyListObject *)operand1;
10887 PyListObject *b = (PyListObject *)operand2;
10889 bool found =
false;
10890 nuitka_bool res = NUITKA_BOOL_TRUE;
10893 for (i = 0; i < Py_SIZE(a) && i < Py_SIZE(b); i++) {
10894 PyObject *aa = a->ob_item[i];
10895 PyObject *bb = b->ob_item[i];
10903 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
10907 if (res == NUITKA_BOOL_EXCEPTION) {
10908 return NUITKA_BOOL_EXCEPTION;
10911 if (res == NUITKA_BOOL_FALSE) {
10917 if (found ==
false) {
10918 bool r = Py_SIZE(a) < Py_SIZE(b);
10921 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10926 return RICH_COMPARE_LT_NBOOL_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
10929nuitka_bool RICH_COMPARE_LT_NBOOL_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
10931 if (Py_TYPE(operand1) == &PyList_Type) {
10932 return COMPARE_LT_NBOOL_LIST_LIST(operand1, operand2);
10935#if PYTHON_VERSION < 0x300
10936 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10937 return NUITKA_BOOL_EXCEPTION;
10940 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10941 return NUITKA_BOOL_EXCEPTION;
10945 PyTypeObject *type1 = Py_TYPE(operand1);
10947#if PYTHON_VERSION < 0x300
10949 if (type1 == &PyList_Type && !0) {
10951 richcmpfunc frich = PyList_Type.tp_richcompare;
10953 if (frich != NULL) {
10954 PyObject *result = (*frich)(operand1, operand2, Py_LT);
10956 if (result != Py_NotImplemented) {
10957 Py_LeaveRecursiveCall();
10959 if (unlikely(result == NULL)) {
10960 return NUITKA_BOOL_EXCEPTION;
10964 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10970 Py_DECREF_IMMORTAL(result);
10974 cmpfunc fcmp = NULL;
10976 if (fcmp != NULL) {
10977 int c = (*fcmp)(operand1, operand2);
10978 c = adjust_tp_compare(c);
10980 Py_LeaveRecursiveCall();
10983 return NUITKA_BOOL_EXCEPTION;
11006 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
11010 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11019 if (type1 != &PyList_Type && 0) {
11020 f = PyList_Type.tp_richcompare;
11023 PyObject *result = (*f)(operand2, operand1, Py_GT);
11025 if (result != Py_NotImplemented) {
11026 Py_LeaveRecursiveCall();
11028 if (unlikely(result == NULL)) {
11029 return NUITKA_BOOL_EXCEPTION;
11033 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11039 Py_DECREF_IMMORTAL(result);
11043 f = TP_RICHCOMPARE(type1);
11045 PyObject *result = (*f)(operand1, operand2, Py_LT);
11047 if (result != Py_NotImplemented) {
11048 Py_LeaveRecursiveCall();
11050 if (unlikely(result == NULL)) {
11051 return NUITKA_BOOL_EXCEPTION;
11055 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11061 Py_DECREF_IMMORTAL(result);
11064 f = PyList_Type.tp_richcompare;
11066 PyObject *result = (*f)(operand2, operand1, Py_GT);
11068 if (result != Py_NotImplemented) {
11069 Py_LeaveRecursiveCall();
11071 if (unlikely(result == NULL)) {
11072 return NUITKA_BOOL_EXCEPTION;
11076 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11082 Py_DECREF_IMMORTAL(result);
11087 if (PyInstance_Check(operand1)) {
11088 cmpfunc fcmp = type1->tp_compare;
11089 c = (*fcmp)(operand1, operand2);
11091 cmpfunc fcmp = NULL;
11092 c = (*fcmp)(operand1, operand2);
11094 c = try_3way_compare(operand1, operand2);
11098 if (type1 == &PyList_Type) {
11099 Py_uintptr_t aa = (Py_uintptr_t)operand1;
11100 Py_uintptr_t bb = (Py_uintptr_t)operand2;
11102 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11103 }
else if (operand1 == Py_None) {
11106 }
else if (operand2 == Py_None) {
11109 }
else if (PyNumber_Check(operand1)) {
11112 if (PyNumber_Check(operand2)) {
11114 Py_uintptr_t aa = (Py_uintptr_t)type1;
11115 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
11117 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11121 }
else if (PyNumber_Check(operand2)) {
11125 int s = strcmp(type1->tp_name,
"list");
11129 }
else if (s > 0) {
11133 Py_uintptr_t aa = (Py_uintptr_t)type1;
11134 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
11136 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11141 Py_LeaveRecursiveCall();
11143 if (unlikely(c <= -2)) {
11144 return NUITKA_BOOL_EXCEPTION;
11169 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11173 bool checked_reverse_op =
false;
11176 if (type1 != &PyList_Type && Nuitka_Type_IsSubtype(&PyList_Type, type1)) {
11177 f = PyList_Type.tp_richcompare;
11180 checked_reverse_op =
true;
11182 PyObject *result = (*f)(operand2, operand1, Py_GT);
11184 if (result != Py_NotImplemented) {
11185 Py_LeaveRecursiveCall();
11187 if (unlikely(result == NULL)) {
11188 return NUITKA_BOOL_EXCEPTION;
11192 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11198 Py_DECREF_IMMORTAL(result);
11202 f = TP_RICHCOMPARE(type1);
11205 PyObject *result = (*f)(operand1, operand2, Py_LT);
11207 if (result != Py_NotImplemented) {
11208 Py_LeaveRecursiveCall();
11210 if (unlikely(result == NULL)) {
11211 return NUITKA_BOOL_EXCEPTION;
11215 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11221 Py_DECREF_IMMORTAL(result);
11224 if (checked_reverse_op ==
false) {
11225 f = PyList_Type.tp_richcompare;
11228 PyObject *result = (*f)(operand2, operand1, Py_GT);
11230 if (result != Py_NotImplemented) {
11231 Py_LeaveRecursiveCall();
11233 if (unlikely(result == NULL)) {
11234 return NUITKA_BOOL_EXCEPTION;
11238 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11244 Py_DECREF_IMMORTAL(result);
11248 Py_LeaveRecursiveCall();
11254 bool r = operand1 == operand2;
11255 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11260 bool r = operand1 != operand2;
11261 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11266#if PYTHON_VERSION < 0x360
11267 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() < list()", type1->tp_name);
11269 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of '%s' and 'list'", type1->tp_name);
11271 return NUITKA_BOOL_EXCEPTION;
11277nuitka_bool RICH_COMPARE_LT_NBOOL_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
11279 if (&PyList_Type == Py_TYPE(operand2)) {
11280 return COMPARE_LT_NBOOL_LIST_LIST(operand1, operand2);
11283#if PYTHON_VERSION < 0x300
11284 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
11285 return NUITKA_BOOL_EXCEPTION;
11288 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
11289 return NUITKA_BOOL_EXCEPTION;
11293 PyTypeObject *type2 = Py_TYPE(operand2);
11295#if PYTHON_VERSION < 0x300
11297 if (&PyList_Type == type2 && !0) {
11299 richcmpfunc frich = PyList_Type.tp_richcompare;
11301 if (frich != NULL) {
11302 PyObject *result = (*frich)(operand1, operand2, Py_LT);
11304 if (result != Py_NotImplemented) {
11305 Py_LeaveRecursiveCall();
11307 if (unlikely(result == NULL)) {
11308 return NUITKA_BOOL_EXCEPTION;
11312 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11318 Py_DECREF_IMMORTAL(result);
11322 cmpfunc fcmp = NULL;
11324 if (fcmp != NULL) {
11325 int c = (*fcmp)(operand1, operand2);
11326 c = adjust_tp_compare(c);
11328 Py_LeaveRecursiveCall();
11331 return NUITKA_BOOL_EXCEPTION;
11354 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
11358 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11367 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
11368 f = TP_RICHCOMPARE(type2);
11371 PyObject *result = (*f)(operand2, operand1, Py_GT);
11373 if (result != Py_NotImplemented) {
11374 Py_LeaveRecursiveCall();
11376 if (unlikely(result == NULL)) {
11377 return NUITKA_BOOL_EXCEPTION;
11381 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11387 Py_DECREF_IMMORTAL(result);
11391 f = PyList_Type.tp_richcompare;
11393 PyObject *result = (*f)(operand1, operand2, Py_LT);
11395 if (result != Py_NotImplemented) {
11396 Py_LeaveRecursiveCall();
11398 if (unlikely(result == NULL)) {
11399 return NUITKA_BOOL_EXCEPTION;
11403 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11409 Py_DECREF_IMMORTAL(result);
11412 f = TP_RICHCOMPARE(type2);
11414 PyObject *result = (*f)(operand2, operand1, Py_GT);
11416 if (result != Py_NotImplemented) {
11417 Py_LeaveRecursiveCall();
11419 if (unlikely(result == NULL)) {
11420 return NUITKA_BOOL_EXCEPTION;
11424 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11430 Py_DECREF_IMMORTAL(result);
11436 cmpfunc fcmp = NULL;
11437 c = (*fcmp)(operand1, operand2);
11438 }
else if (PyInstance_Check(operand2)) {
11439 cmpfunc fcmp = type2->tp_compare;
11440 c = (*fcmp)(operand1, operand2);
11442 c = try_3way_compare(operand1, operand2);
11446 if (&PyList_Type == type2) {
11447 Py_uintptr_t aa = (Py_uintptr_t)operand1;
11448 Py_uintptr_t bb = (Py_uintptr_t)operand2;
11450 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11451 }
else if (operand1 == Py_None) {
11454 }
else if (operand2 == Py_None) {
11457 }
else if (PyNumber_Check(operand1)) {
11460 if (PyNumber_Check(operand2)) {
11462 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
11463 Py_uintptr_t bb = (Py_uintptr_t)type2;
11465 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11469 }
else if (PyNumber_Check(operand2)) {
11473 int s = strcmp(
"list", type2->tp_name);
11477 }
else if (s > 0) {
11481 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
11482 Py_uintptr_t bb = (Py_uintptr_t)type2;
11484 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11489 Py_LeaveRecursiveCall();
11491 if (unlikely(c <= -2)) {
11492 return NUITKA_BOOL_EXCEPTION;
11517 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11521 bool checked_reverse_op =
false;
11524 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
11525 f = TP_RICHCOMPARE(type2);
11528 checked_reverse_op =
true;
11530 PyObject *result = (*f)(operand2, operand1, Py_GT);
11532 if (result != Py_NotImplemented) {
11533 Py_LeaveRecursiveCall();
11535 if (unlikely(result == NULL)) {
11536 return NUITKA_BOOL_EXCEPTION;
11540 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11546 Py_DECREF_IMMORTAL(result);
11550 f = PyList_Type.tp_richcompare;
11553 PyObject *result = (*f)(operand1, operand2, Py_LT);
11555 if (result != Py_NotImplemented) {
11556 Py_LeaveRecursiveCall();
11558 if (unlikely(result == NULL)) {
11559 return NUITKA_BOOL_EXCEPTION;
11563 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11569 Py_DECREF_IMMORTAL(result);
11572 if (checked_reverse_op ==
false) {
11573 f = TP_RICHCOMPARE(type2);
11576 PyObject *result = (*f)(operand2, operand1, Py_GT);
11578 if (result != Py_NotImplemented) {
11579 Py_LeaveRecursiveCall();
11581 if (unlikely(result == NULL)) {
11582 return NUITKA_BOOL_EXCEPTION;
11586 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11592 Py_DECREF_IMMORTAL(result);
11596 Py_LeaveRecursiveCall();
11602 bool r = operand1 == operand2;
11603 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11608 bool r = operand1 != operand2;
11609 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11614#if PYTHON_VERSION < 0x360
11615 PyErr_Format(PyExc_TypeError,
"unorderable types: list() < %s()", type2->tp_name);
11617 PyErr_Format(PyExc_TypeError,
"'<' not supported between instances of 'list' and '%s'", type2->tp_name);
11619 return NUITKA_BOOL_EXCEPTION;
11625nuitka_bool RICH_COMPARE_LT_NBOOL_LIST_LIST(PyObject *operand1, PyObject *operand2) {
11627 return COMPARE_LT_NBOOL_LIST_LIST(operand1, operand2);
11630static PyObject *COMPARE_LT_OBJECT_LONG_CLONG(PyObject *operand1,
long operand2) {
11631 CHECK_OBJECT(operand1);
11632 assert(PyLong_CheckExact(operand1));
11634 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11636 bool operand2_is_negative;
11637 unsigned long operand2_abs_ival;
11639 if (operand2 < 0) {
11640 operand2_abs_ival = (
unsigned long)(-1 - operand2) + 1;
11641 operand2_is_negative =
true;
11643 operand2_abs_ival = (
unsigned long)operand2;
11644 operand2_is_negative =
false;
11647 Py_ssize_t operand2_digit_count = 0;
11648 digit operand2_digits[5] = {0};
11650 unsigned long t = operand2_abs_ival;
11653 operand2_digit_count += 1;
11654 assert(operand2_digit_count <= (Py_ssize_t)(
sizeof(operand2_digit_count) /
sizeof(digit)));
11656 operand2_digits[operand2_digit_count] = (digit)(t & PyLong_MASK);
11657 t >>= PyLong_SHIFT;
11661 NUITKA_MAY_BE_UNUSED Py_ssize_t operand2_size =
11662 operand2_is_negative ==
false ? operand2_digit_count : -operand2_digit_count;
11666 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) != operand2_size) {
11667 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - operand2_size < 0;
11669 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11672 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != operand2_digits[i]) {
11673 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] < operand2_digits[i];
11674 if (Nuitka_LongIsNegative(operand1_long_object)) {
11683 PyObject *result = BOOL_FROM(r);
11684 Py_INCREF_IMMORTAL(result);
11687#if PYTHON_VERSION < 0x300
11689PyObject *RICH_COMPARE_LT_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
11691 return COMPARE_LT_OBJECT_LONG_CLONG(operand1, PyInt_AS_LONG(operand1));
11695static bool COMPARE_LT_CBOOL_LONG_CLONG(PyObject *operand1,
long operand2) {
11696 CHECK_OBJECT(operand1);
11697 assert(PyLong_CheckExact(operand1));
11699 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11701 bool operand2_is_negative;
11702 unsigned long operand2_abs_ival;
11704 if (operand2 < 0) {
11705 operand2_abs_ival = (
unsigned long)(-1 - operand2) + 1;
11706 operand2_is_negative =
true;
11708 operand2_abs_ival = (
unsigned long)operand2;
11709 operand2_is_negative =
false;
11712 Py_ssize_t operand2_digit_count = 0;
11713 digit operand2_digits[5] = {0};
11715 unsigned long t = operand2_abs_ival;
11718 operand2_digit_count += 1;
11719 assert(operand2_digit_count <= (Py_ssize_t)(
sizeof(operand2_digit_count) /
sizeof(digit)));
11721 operand2_digits[operand2_digit_count] = (digit)(t & PyLong_MASK);
11722 t >>= PyLong_SHIFT;
11726 NUITKA_MAY_BE_UNUSED Py_ssize_t operand2_size =
11727 operand2_is_negative ==
false ? operand2_digit_count : -operand2_digit_count;
11731 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) != operand2_size) {
11732 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - operand2_size < 0;
11734 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11737 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != operand2_digits[i]) {
11738 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] < operand2_digits[i];
11739 if (Nuitka_LongIsNegative(operand1_long_object)) {
11752#if PYTHON_VERSION < 0x300
11754bool RICH_COMPARE_LT_CBOOL_LONG_INT(PyObject *operand1, PyObject *operand2) {
11756 return COMPARE_LT_CBOOL_LONG_CLONG(operand1, PyInt_AS_LONG(operand1));
11760#if PYTHON_VERSION < 0x300
11761static PyObject *COMPARE_LT_OBJECT_INT_CLONG(PyObject *operand1,
long operand2) {
11762 CHECK_OBJECT(operand1);
11763 assert(PyInt_CheckExact(operand1));
11765 const long a = PyInt_AS_LONG(operand1);
11766 const long b = operand2;
11771 PyObject *result = BOOL_FROM(r);
11772 Py_INCREF_IMMORTAL(result);
11776#if PYTHON_VERSION < 0x300
11778PyObject *RICH_COMPARE_LT_OBJECT_INT_CLONG(PyObject *operand1,
long operand2) {
11780 return COMPARE_LT_OBJECT_INT_CLONG(operand1, operand2);
11784#if PYTHON_VERSION < 0x300
11785static bool COMPARE_LT_CBOOL_INT_CLONG(PyObject *operand1,
long operand2) {
11786 CHECK_OBJECT(operand1);
11787 assert(PyInt_CheckExact(operand1));
11789 const long a = PyInt_AS_LONG(operand1);
11790 const long b = operand2;
11800#if PYTHON_VERSION < 0x300
11802bool RICH_COMPARE_LT_CBOOL_INT_CLONG(PyObject *operand1,
long operand2) {
11804 return COMPARE_LT_CBOOL_INT_CLONG(operand1, operand2);
11808static PyObject *COMPARE_LT_OBJECT_LONG_DIGIT(PyObject *operand1,
long operand2) {
11809 CHECK_OBJECT(operand1);
11810 assert(PyLong_CheckExact(operand1));
11811 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
11813 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11817 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
11818 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1))) {
11819 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) -
11820 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1)) <
11823 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11826 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != (digit)Py_ABS(operand2)) {
11827 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] < (digit)Py_ABS(operand2);
11828 if (Nuitka_LongIsNegative(operand1_long_object)) {
11837 PyObject *result = BOOL_FROM(r);
11838 Py_INCREF_IMMORTAL(result);
11843PyObject *RICH_COMPARE_LT_OBJECT_LONG_DIGIT(PyObject *operand1,
long operand2) {
11845 return COMPARE_LT_OBJECT_LONG_DIGIT(operand1, operand2);
11848static bool COMPARE_LT_CBOOL_LONG_DIGIT(PyObject *operand1,
long operand2) {
11849 CHECK_OBJECT(operand1);
11850 assert(PyLong_CheckExact(operand1));
11851 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
11853 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11857 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
11858 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1))) {
11859 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) -
11860 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1)) <
11863 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11866 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != (digit)Py_ABS(operand2)) {
11867 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] < (digit)Py_ABS(operand2);
11868 if (Nuitka_LongIsNegative(operand1_long_object)) {
11883bool RICH_COMPARE_LT_CBOOL_LONG_DIGIT(PyObject *operand1,
long operand2) {
11885 return COMPARE_LT_CBOOL_LONG_DIGIT(operand1, operand2);
11888static PyObject *COMPARE_LT_OBJECT_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11889 CHECK_OBJECT(operand1);
11890 assert(PyFloat_CheckExact(operand1));
11892 const double a = PyFloat_AS_DOUBLE(operand1);
11893 const double b = operand2;
11898 PyObject *result = BOOL_FROM(r);
11899 Py_INCREF_IMMORTAL(result);
11903PyObject *RICH_COMPARE_LT_OBJECT_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11905 return COMPARE_LT_OBJECT_FLOAT_CFLOAT(operand1, operand2);
11908static bool COMPARE_LT_CBOOL_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11909 CHECK_OBJECT(operand1);
11910 assert(PyFloat_CheckExact(operand1));
11912 const double a = PyFloat_AS_DOUBLE(operand1);
11913 const double b = operand2;
11923bool RICH_COMPARE_LT_CBOOL_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11925 return COMPARE_LT_CBOOL_FLOAT_CFLOAT(operand1, operand2);