7#include "nuitka/prelude.h"
12#if PYTHON_VERSION < 0x300
13static PyObject *COMPARE_GT_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_GT_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_GT_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
51#if PYTHON_VERSION < 0x300
52 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
53 return COMPARE_GT_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_GT);
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_LT);
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_GT);
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_LT);
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_LT);
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_GT);
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_LT);
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_GT_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
347#if PYTHON_VERSION < 0x300
348 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
349 return COMPARE_GT_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_GT);
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_LT);
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_GT);
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_LT);
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_LT);
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_GT);
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_LT);
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_GT_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_GT_OBJECT_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
748 if (Py_TYPE(operand1) == &PyString_Type) {
749 return COMPARE_GT_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_GT);
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_LT);
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_GT);
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_LT);
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_LT);
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_GT);
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_LT);
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_GT_OBJECT_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
1042 if (&PyString_Type == Py_TYPE(operand2)) {
1043 return COMPARE_GT_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_GT);
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_LT);
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_GT);
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_LT);
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_LT);
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_GT);
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_LT);
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
1333static bool COMPARE_GT_CBOOL_STR_STR(PyObject *operand1, PyObject *operand2) {
1334 CHECK_OBJECT(operand1);
1335 assert(PyString_CheckExact(operand1));
1336 CHECK_OBJECT(operand2);
1337 assert(PyString_CheckExact(operand2));
1339 PyStringObject *a = (PyStringObject *)operand1;
1340 PyStringObject *b = (PyStringObject *)operand2;
1343 if (operand1 == operand2) {
1352 Py_ssize_t len_a = Py_SIZE(operand1);
1353 Py_ssize_t len_b = Py_SIZE(operand2);
1355 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
1359 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
1362 c = memcmp(a->ob_sval, b->ob_sval, min_len);
1369 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
1375 bool result = c != 0;
1380#if PYTHON_VERSION < 0x300
1382nuitka_bool RICH_COMPARE_GT_NBOOL_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
1384 if (Py_TYPE(operand1) == &PyString_Type) {
1385 return COMPARE_GT_CBOOL_STR_STR(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1388#if PYTHON_VERSION < 0x300
1389 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1390 return NUITKA_BOOL_EXCEPTION;
1393 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1394 return NUITKA_BOOL_EXCEPTION;
1398 PyTypeObject *type1 = Py_TYPE(operand1);
1400#if PYTHON_VERSION < 0x300
1402 if (type1 == &PyString_Type && !0) {
1404 richcmpfunc frich = PyString_Type.tp_richcompare;
1406 if (frich != NULL) {
1407 PyObject *result = (*frich)(operand1, operand2, Py_GT);
1409 if (result != Py_NotImplemented) {
1410 Py_LeaveRecursiveCall();
1412 if (unlikely(result == NULL)) {
1413 return NUITKA_BOOL_EXCEPTION;
1417 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1423 Py_DECREF_IMMORTAL(result);
1427 cmpfunc fcmp = NULL;
1430 int c = (*fcmp)(operand1, operand2);
1431 c = adjust_tp_compare(c);
1433 Py_LeaveRecursiveCall();
1436 return NUITKA_BOOL_EXCEPTION;
1459 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1463 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1472 if (type1 != &PyString_Type && 0) {
1473 f = PyString_Type.tp_richcompare;
1476 PyObject *result = (*f)(operand2, operand1, Py_LT);
1478 if (result != Py_NotImplemented) {
1479 Py_LeaveRecursiveCall();
1481 if (unlikely(result == NULL)) {
1482 return NUITKA_BOOL_EXCEPTION;
1486 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1492 Py_DECREF_IMMORTAL(result);
1496 f = TP_RICHCOMPARE(type1);
1498 PyObject *result = (*f)(operand1, operand2, Py_GT);
1500 if (result != Py_NotImplemented) {
1501 Py_LeaveRecursiveCall();
1503 if (unlikely(result == NULL)) {
1504 return NUITKA_BOOL_EXCEPTION;
1508 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1514 Py_DECREF_IMMORTAL(result);
1517 f = PyString_Type.tp_richcompare;
1519 PyObject *result = (*f)(operand2, operand1, Py_LT);
1521 if (result != Py_NotImplemented) {
1522 Py_LeaveRecursiveCall();
1524 if (unlikely(result == NULL)) {
1525 return NUITKA_BOOL_EXCEPTION;
1529 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1535 Py_DECREF_IMMORTAL(result);
1540 if (PyInstance_Check(operand1)) {
1541 cmpfunc fcmp = type1->tp_compare;
1542 c = (*fcmp)(operand1, operand2);
1544 cmpfunc fcmp = NULL;
1545 c = (*fcmp)(operand1, operand2);
1547 c = try_3way_compare(operand1, operand2);
1551 if (type1 == &PyString_Type) {
1552 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1553 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1555 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1556 }
else if (operand1 == Py_None) {
1559 }
else if (operand2 == Py_None) {
1562 }
else if (PyNumber_Check(operand1)) {
1565 if (PyNumber_Check(operand2)) {
1567 Py_uintptr_t aa = (Py_uintptr_t)type1;
1568 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
1570 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1574 }
else if (PyNumber_Check(operand2)) {
1578 int s = strcmp(type1->tp_name,
"str");
1586 Py_uintptr_t aa = (Py_uintptr_t)type1;
1587 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
1589 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1594 Py_LeaveRecursiveCall();
1596 if (unlikely(c <= -2)) {
1597 return NUITKA_BOOL_EXCEPTION;
1622 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1626 bool checked_reverse_op =
false;
1629 if (type1 != &PyString_Type && Nuitka_Type_IsSubtype(&PyString_Type, type1)) {
1630 f = PyString_Type.tp_richcompare;
1633 checked_reverse_op =
true;
1635 PyObject *result = (*f)(operand2, operand1, Py_LT);
1637 if (result != Py_NotImplemented) {
1638 Py_LeaveRecursiveCall();
1640 if (unlikely(result == NULL)) {
1641 return NUITKA_BOOL_EXCEPTION;
1645 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1651 Py_DECREF_IMMORTAL(result);
1655 f = TP_RICHCOMPARE(type1);
1658 PyObject *result = (*f)(operand1, operand2, Py_GT);
1660 if (result != Py_NotImplemented) {
1661 Py_LeaveRecursiveCall();
1663 if (unlikely(result == NULL)) {
1664 return NUITKA_BOOL_EXCEPTION;
1668 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1674 Py_DECREF_IMMORTAL(result);
1677 if (checked_reverse_op ==
false) {
1678 f = PyString_Type.tp_richcompare;
1681 PyObject *result = (*f)(operand2, operand1, Py_LT);
1683 if (result != Py_NotImplemented) {
1684 Py_LeaveRecursiveCall();
1686 if (unlikely(result == NULL)) {
1687 return NUITKA_BOOL_EXCEPTION;
1691 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1697 Py_DECREF_IMMORTAL(result);
1701 Py_LeaveRecursiveCall();
1707 bool r = operand1 == operand2;
1708 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1713 bool r = operand1 != operand2;
1714 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1719#if PYTHON_VERSION < 0x360
1720 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > str()", type1->tp_name);
1722 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'str'", type1->tp_name);
1724 return NUITKA_BOOL_EXCEPTION;
1730#if PYTHON_VERSION < 0x300
1732nuitka_bool RICH_COMPARE_GT_NBOOL_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
1734 if (&PyString_Type == Py_TYPE(operand2)) {
1735 return COMPARE_GT_CBOOL_STR_STR(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1738#if PYTHON_VERSION < 0x300
1739 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1740 return NUITKA_BOOL_EXCEPTION;
1743 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1744 return NUITKA_BOOL_EXCEPTION;
1748 PyTypeObject *type2 = Py_TYPE(operand2);
1750#if PYTHON_VERSION < 0x300
1752 if (&PyString_Type == type2 && !0) {
1754 richcmpfunc frich = PyString_Type.tp_richcompare;
1756 if (frich != NULL) {
1757 PyObject *result = (*frich)(operand1, operand2, Py_GT);
1759 if (result != Py_NotImplemented) {
1760 Py_LeaveRecursiveCall();
1762 if (unlikely(result == NULL)) {
1763 return NUITKA_BOOL_EXCEPTION;
1767 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1773 Py_DECREF_IMMORTAL(result);
1777 cmpfunc fcmp = NULL;
1780 int c = (*fcmp)(operand1, operand2);
1781 c = adjust_tp_compare(c);
1783 Py_LeaveRecursiveCall();
1786 return NUITKA_BOOL_EXCEPTION;
1809 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1813 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1822 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1823 f = TP_RICHCOMPARE(type2);
1826 PyObject *result = (*f)(operand2, operand1, Py_LT);
1828 if (result != Py_NotImplemented) {
1829 Py_LeaveRecursiveCall();
1831 if (unlikely(result == NULL)) {
1832 return NUITKA_BOOL_EXCEPTION;
1836 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1842 Py_DECREF_IMMORTAL(result);
1846 f = PyString_Type.tp_richcompare;
1848 PyObject *result = (*f)(operand1, operand2, Py_GT);
1850 if (result != Py_NotImplemented) {
1851 Py_LeaveRecursiveCall();
1853 if (unlikely(result == NULL)) {
1854 return NUITKA_BOOL_EXCEPTION;
1858 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1864 Py_DECREF_IMMORTAL(result);
1867 f = TP_RICHCOMPARE(type2);
1869 PyObject *result = (*f)(operand2, operand1, Py_LT);
1871 if (result != Py_NotImplemented) {
1872 Py_LeaveRecursiveCall();
1874 if (unlikely(result == NULL)) {
1875 return NUITKA_BOOL_EXCEPTION;
1879 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1885 Py_DECREF_IMMORTAL(result);
1891 cmpfunc fcmp = NULL;
1892 c = (*fcmp)(operand1, operand2);
1893 }
else if (PyInstance_Check(operand2)) {
1894 cmpfunc fcmp = type2->tp_compare;
1895 c = (*fcmp)(operand1, operand2);
1897 c = try_3way_compare(operand1, operand2);
1901 if (&PyString_Type == type2) {
1902 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1903 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1905 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1906 }
else if (operand1 == Py_None) {
1909 }
else if (operand2 == Py_None) {
1912 }
else if (PyNumber_Check(operand1)) {
1915 if (PyNumber_Check(operand2)) {
1917 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1918 Py_uintptr_t bb = (Py_uintptr_t)type2;
1920 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1924 }
else if (PyNumber_Check(operand2)) {
1928 int s = strcmp(
"str", type2->tp_name);
1936 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1937 Py_uintptr_t bb = (Py_uintptr_t)type2;
1939 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1944 Py_LeaveRecursiveCall();
1946 if (unlikely(c <= -2)) {
1947 return NUITKA_BOOL_EXCEPTION;
1972 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1976 bool checked_reverse_op =
false;
1979 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1980 f = TP_RICHCOMPARE(type2);
1983 checked_reverse_op =
true;
1985 PyObject *result = (*f)(operand2, operand1, Py_LT);
1987 if (result != Py_NotImplemented) {
1988 Py_LeaveRecursiveCall();
1990 if (unlikely(result == NULL)) {
1991 return NUITKA_BOOL_EXCEPTION;
1995 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2001 Py_DECREF_IMMORTAL(result);
2005 f = PyString_Type.tp_richcompare;
2008 PyObject *result = (*f)(operand1, operand2, Py_GT);
2010 if (result != Py_NotImplemented) {
2011 Py_LeaveRecursiveCall();
2013 if (unlikely(result == NULL)) {
2014 return NUITKA_BOOL_EXCEPTION;
2018 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2024 Py_DECREF_IMMORTAL(result);
2027 if (checked_reverse_op ==
false) {
2028 f = TP_RICHCOMPARE(type2);
2031 PyObject *result = (*f)(operand2, operand1, Py_LT);
2033 if (result != Py_NotImplemented) {
2034 Py_LeaveRecursiveCall();
2036 if (unlikely(result == NULL)) {
2037 return NUITKA_BOOL_EXCEPTION;
2041 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2047 Py_DECREF_IMMORTAL(result);
2051 Py_LeaveRecursiveCall();
2057 bool r = operand1 == operand2;
2058 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2063 bool r = operand1 != operand2;
2064 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2069#if PYTHON_VERSION < 0x360
2070 PyErr_Format(PyExc_TypeError,
"unorderable types: str() > %s()", type2->tp_name);
2072 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'str' and '%s'", type2->tp_name);
2074 return NUITKA_BOOL_EXCEPTION;
2080static PyObject *COMPARE_GT_OBJECT_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2081 CHECK_OBJECT(operand1);
2082 assert(PyUnicode_CheckExact(operand1));
2083 CHECK_OBJECT(operand2);
2084 assert(PyUnicode_CheckExact(operand2));
2086 PyUnicodeObject *a = (PyUnicodeObject *)operand1;
2087 PyUnicodeObject *b = (PyUnicodeObject *)operand2;
2090 if (operand1 == operand2) {
2094 PyObject *result = BOOL_FROM(r);
2095 Py_INCREF_IMMORTAL(result);
2099 PyObject *r = PyUnicode_RichCompare((PyObject *)a, (PyObject *)b, Py_GT);
2105PyObject *RICH_COMPARE_GT_OBJECT_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
2107 if (Py_TYPE(operand1) == &PyUnicode_Type) {
2108 return COMPARE_GT_OBJECT_UNICODE_UNICODE(operand1, operand2);
2111#if PYTHON_VERSION < 0x300
2112 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2116 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2121 PyTypeObject *type1 = Py_TYPE(operand1);
2123#if PYTHON_VERSION < 0x300
2125 if (type1 == &PyUnicode_Type && !0) {
2127 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2129 if (frich != NULL) {
2130 PyObject *result = (*frich)(operand1, operand2, Py_GT);
2132 if (result != Py_NotImplemented) {
2133 Py_LeaveRecursiveCall();
2138 Py_DECREF_IMMORTAL(result);
2142 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2145 int c = (*fcmp)(operand1, operand2);
2146 c = adjust_tp_compare(c);
2148 Py_LeaveRecursiveCall();
2174 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2178 PyObject *result = BOOL_FROM(r);
2179 Py_INCREF_IMMORTAL(result);
2187 if (type1 != &PyUnicode_Type && 0) {
2188 f = PyUnicode_Type.tp_richcompare;
2191 PyObject *result = (*f)(operand2, operand1, Py_LT);
2193 if (result != Py_NotImplemented) {
2194 Py_LeaveRecursiveCall();
2199 Py_DECREF_IMMORTAL(result);
2203 f = TP_RICHCOMPARE(type1);
2205 PyObject *result = (*f)(operand1, operand2, Py_GT);
2207 if (result != Py_NotImplemented) {
2208 Py_LeaveRecursiveCall();
2213 Py_DECREF_IMMORTAL(result);
2216 f = PyUnicode_Type.tp_richcompare;
2218 PyObject *result = (*f)(operand2, operand1, Py_LT);
2220 if (result != Py_NotImplemented) {
2221 Py_LeaveRecursiveCall();
2226 Py_DECREF_IMMORTAL(result);
2231 if (PyInstance_Check(operand1)) {
2232 cmpfunc fcmp = type1->tp_compare;
2233 c = (*fcmp)(operand1, operand2);
2235 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2236 c = (*fcmp)(operand1, operand2);
2238 c = try_3way_compare(operand1, operand2);
2242 if (type1 == &PyUnicode_Type) {
2243 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2244 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2246 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2247 }
else if (operand1 == Py_None) {
2250 }
else if (operand2 == Py_None) {
2253 }
else if (PyNumber_Check(operand1)) {
2256 if (PyNumber_Check(operand2)) {
2258 Py_uintptr_t aa = (Py_uintptr_t)type1;
2259 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2261 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2265 }
else if (PyNumber_Check(operand2)) {
2269 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"unicode" :
"str"));
2277 Py_uintptr_t aa = (Py_uintptr_t)type1;
2278 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2280 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2285 Py_LeaveRecursiveCall();
2287 if (unlikely(c <= -2)) {
2313 PyObject *result = BOOL_FROM(r);
2314 Py_INCREF_IMMORTAL(result);
2317 bool checked_reverse_op =
false;
2320 if (type1 != &PyUnicode_Type && Nuitka_Type_IsSubtype(&PyUnicode_Type, type1)) {
2321 f = PyUnicode_Type.tp_richcompare;
2324 checked_reverse_op =
true;
2326 PyObject *result = (*f)(operand2, operand1, Py_LT);
2328 if (result != Py_NotImplemented) {
2329 Py_LeaveRecursiveCall();
2334 Py_DECREF_IMMORTAL(result);
2338 f = TP_RICHCOMPARE(type1);
2341 PyObject *result = (*f)(operand1, operand2, Py_GT);
2343 if (result != Py_NotImplemented) {
2344 Py_LeaveRecursiveCall();
2349 Py_DECREF_IMMORTAL(result);
2352 if (checked_reverse_op ==
false) {
2353 f = PyUnicode_Type.tp_richcompare;
2356 PyObject *result = (*f)(operand2, operand1, Py_LT);
2358 if (result != Py_NotImplemented) {
2359 Py_LeaveRecursiveCall();
2364 Py_DECREF_IMMORTAL(result);
2368 Py_LeaveRecursiveCall();
2374 bool r = operand1 == operand2;
2375 PyObject *result = BOOL_FROM(r);
2376 Py_INCREF_IMMORTAL(result);
2380 bool r = operand1 != operand2;
2381 PyObject *result = BOOL_FROM(r);
2382 Py_INCREF_IMMORTAL(result);
2386#if PYTHON_VERSION < 0x300
2387 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > unicode()", type1->tp_name);
2388#elif PYTHON_VERSION < 0x360
2389 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > str()", type1->tp_name);
2391 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'str'", type1->tp_name);
2399PyObject *RICH_COMPARE_GT_OBJECT_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
2401 if (&PyUnicode_Type == Py_TYPE(operand2)) {
2402 return COMPARE_GT_OBJECT_UNICODE_UNICODE(operand1, operand2);
2405#if PYTHON_VERSION < 0x300
2406 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2410 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2415 PyTypeObject *type2 = Py_TYPE(operand2);
2417#if PYTHON_VERSION < 0x300
2419 if (&PyUnicode_Type == type2 && !0) {
2421 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2423 if (frich != NULL) {
2424 PyObject *result = (*frich)(operand1, operand2, Py_GT);
2426 if (result != Py_NotImplemented) {
2427 Py_LeaveRecursiveCall();
2432 Py_DECREF_IMMORTAL(result);
2436 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2439 int c = (*fcmp)(operand1, operand2);
2440 c = adjust_tp_compare(c);
2442 Py_LeaveRecursiveCall();
2468 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2472 PyObject *result = BOOL_FROM(r);
2473 Py_INCREF_IMMORTAL(result);
2481 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
2482 f = TP_RICHCOMPARE(type2);
2485 PyObject *result = (*f)(operand2, operand1, Py_LT);
2487 if (result != Py_NotImplemented) {
2488 Py_LeaveRecursiveCall();
2493 Py_DECREF_IMMORTAL(result);
2497 f = PyUnicode_Type.tp_richcompare;
2499 PyObject *result = (*f)(operand1, operand2, Py_GT);
2501 if (result != Py_NotImplemented) {
2502 Py_LeaveRecursiveCall();
2507 Py_DECREF_IMMORTAL(result);
2510 f = TP_RICHCOMPARE(type2);
2512 PyObject *result = (*f)(operand2, operand1, Py_LT);
2514 if (result != Py_NotImplemented) {
2515 Py_LeaveRecursiveCall();
2520 Py_DECREF_IMMORTAL(result);
2526 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2527 c = (*fcmp)(operand1, operand2);
2528 }
else if (PyInstance_Check(operand2)) {
2529 cmpfunc fcmp = type2->tp_compare;
2530 c = (*fcmp)(operand1, operand2);
2532 c = try_3way_compare(operand1, operand2);
2536 if (&PyUnicode_Type == type2) {
2537 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2538 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2540 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2541 }
else if (operand1 == Py_None) {
2544 }
else if (operand2 == Py_None) {
2547 }
else if (PyNumber_Check(operand1)) {
2550 if (PyNumber_Check(operand2)) {
2552 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
2553 Py_uintptr_t bb = (Py_uintptr_t)type2;
2555 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2559 }
else if (PyNumber_Check(operand2)) {
2563 int s = strcmp((PYTHON_VERSION < 0x300 ?
"unicode" :
"str"), type2->tp_name);
2571 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
2572 Py_uintptr_t bb = (Py_uintptr_t)type2;
2574 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2579 Py_LeaveRecursiveCall();
2581 if (unlikely(c <= -2)) {
2607 PyObject *result = BOOL_FROM(r);
2608 Py_INCREF_IMMORTAL(result);
2611 bool checked_reverse_op =
false;
2614 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
2615 f = TP_RICHCOMPARE(type2);
2618 checked_reverse_op =
true;
2620 PyObject *result = (*f)(operand2, operand1, Py_LT);
2622 if (result != Py_NotImplemented) {
2623 Py_LeaveRecursiveCall();
2628 Py_DECREF_IMMORTAL(result);
2632 f = PyUnicode_Type.tp_richcompare;
2635 PyObject *result = (*f)(operand1, operand2, Py_GT);
2637 if (result != Py_NotImplemented) {
2638 Py_LeaveRecursiveCall();
2643 Py_DECREF_IMMORTAL(result);
2646 if (checked_reverse_op ==
false) {
2647 f = TP_RICHCOMPARE(type2);
2650 PyObject *result = (*f)(operand2, operand1, Py_LT);
2652 if (result != Py_NotImplemented) {
2653 Py_LeaveRecursiveCall();
2658 Py_DECREF_IMMORTAL(result);
2662 Py_LeaveRecursiveCall();
2668 bool r = operand1 == operand2;
2669 PyObject *result = BOOL_FROM(r);
2670 Py_INCREF_IMMORTAL(result);
2674 bool r = operand1 != operand2;
2675 PyObject *result = BOOL_FROM(r);
2676 Py_INCREF_IMMORTAL(result);
2680#if PYTHON_VERSION < 0x300
2681 PyErr_Format(PyExc_TypeError,
"unorderable types: unicode() > %s()", type2->tp_name);
2682#elif PYTHON_VERSION < 0x360
2683 PyErr_Format(PyExc_TypeError,
"unorderable types: str() > %s()", type2->tp_name);
2685 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'str' and '%s'", type2->tp_name);
2692static bool COMPARE_GT_CBOOL_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2693 CHECK_OBJECT(operand1);
2694 assert(PyUnicode_CheckExact(operand1));
2695 CHECK_OBJECT(operand2);
2696 assert(PyUnicode_CheckExact(operand2));
2698 PyUnicodeObject *a = (PyUnicodeObject *)operand1;
2699 PyUnicodeObject *b = (PyUnicodeObject *)operand2;
2702 if (operand1 == operand2) {
2711 PyObject *r = PyUnicode_RichCompare((PyObject *)a, (PyObject *)b, Py_GT);
2715 bool result = r == Py_True;
2716 Py_DECREF_IMMORTAL(r);
2721nuitka_bool RICH_COMPARE_GT_NBOOL_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
2723 if (Py_TYPE(operand1) == &PyUnicode_Type) {
2724 return COMPARE_GT_CBOOL_UNICODE_UNICODE(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2727#if PYTHON_VERSION < 0x300
2728 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2729 return NUITKA_BOOL_EXCEPTION;
2732 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2733 return NUITKA_BOOL_EXCEPTION;
2737 PyTypeObject *type1 = Py_TYPE(operand1);
2739#if PYTHON_VERSION < 0x300
2741 if (type1 == &PyUnicode_Type && !0) {
2743 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2745 if (frich != NULL) {
2746 PyObject *result = (*frich)(operand1, operand2, Py_GT);
2748 if (result != Py_NotImplemented) {
2749 Py_LeaveRecursiveCall();
2751 if (unlikely(result == NULL)) {
2752 return NUITKA_BOOL_EXCEPTION;
2756 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2762 Py_DECREF_IMMORTAL(result);
2766 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2769 int c = (*fcmp)(operand1, operand2);
2770 c = adjust_tp_compare(c);
2772 Py_LeaveRecursiveCall();
2775 return NUITKA_BOOL_EXCEPTION;
2798 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2802 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2811 if (type1 != &PyUnicode_Type && 0) {
2812 f = PyUnicode_Type.tp_richcompare;
2815 PyObject *result = (*f)(operand2, operand1, Py_LT);
2817 if (result != Py_NotImplemented) {
2818 Py_LeaveRecursiveCall();
2820 if (unlikely(result == NULL)) {
2821 return NUITKA_BOOL_EXCEPTION;
2825 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2831 Py_DECREF_IMMORTAL(result);
2835 f = TP_RICHCOMPARE(type1);
2837 PyObject *result = (*f)(operand1, operand2, Py_GT);
2839 if (result != Py_NotImplemented) {
2840 Py_LeaveRecursiveCall();
2842 if (unlikely(result == NULL)) {
2843 return NUITKA_BOOL_EXCEPTION;
2847 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2853 Py_DECREF_IMMORTAL(result);
2856 f = PyUnicode_Type.tp_richcompare;
2858 PyObject *result = (*f)(operand2, operand1, Py_LT);
2860 if (result != Py_NotImplemented) {
2861 Py_LeaveRecursiveCall();
2863 if (unlikely(result == NULL)) {
2864 return NUITKA_BOOL_EXCEPTION;
2868 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2874 Py_DECREF_IMMORTAL(result);
2879 if (PyInstance_Check(operand1)) {
2880 cmpfunc fcmp = type1->tp_compare;
2881 c = (*fcmp)(operand1, operand2);
2883 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2884 c = (*fcmp)(operand1, operand2);
2886 c = try_3way_compare(operand1, operand2);
2890 if (type1 == &PyUnicode_Type) {
2891 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2892 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2894 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2895 }
else if (operand1 == Py_None) {
2898 }
else if (operand2 == Py_None) {
2901 }
else if (PyNumber_Check(operand1)) {
2904 if (PyNumber_Check(operand2)) {
2906 Py_uintptr_t aa = (Py_uintptr_t)type1;
2907 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2909 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2913 }
else if (PyNumber_Check(operand2)) {
2917 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"unicode" :
"str"));
2925 Py_uintptr_t aa = (Py_uintptr_t)type1;
2926 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2928 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2933 Py_LeaveRecursiveCall();
2935 if (unlikely(c <= -2)) {
2936 return NUITKA_BOOL_EXCEPTION;
2961 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2965 bool checked_reverse_op =
false;
2968 if (type1 != &PyUnicode_Type && Nuitka_Type_IsSubtype(&PyUnicode_Type, type1)) {
2969 f = PyUnicode_Type.tp_richcompare;
2972 checked_reverse_op =
true;
2974 PyObject *result = (*f)(operand2, operand1, Py_LT);
2976 if (result != Py_NotImplemented) {
2977 Py_LeaveRecursiveCall();
2979 if (unlikely(result == NULL)) {
2980 return NUITKA_BOOL_EXCEPTION;
2984 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2990 Py_DECREF_IMMORTAL(result);
2994 f = TP_RICHCOMPARE(type1);
2997 PyObject *result = (*f)(operand1, operand2, Py_GT);
2999 if (result != Py_NotImplemented) {
3000 Py_LeaveRecursiveCall();
3002 if (unlikely(result == NULL)) {
3003 return NUITKA_BOOL_EXCEPTION;
3007 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3013 Py_DECREF_IMMORTAL(result);
3016 if (checked_reverse_op ==
false) {
3017 f = PyUnicode_Type.tp_richcompare;
3020 PyObject *result = (*f)(operand2, operand1, Py_LT);
3022 if (result != Py_NotImplemented) {
3023 Py_LeaveRecursiveCall();
3025 if (unlikely(result == NULL)) {
3026 return NUITKA_BOOL_EXCEPTION;
3030 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3036 Py_DECREF_IMMORTAL(result);
3040 Py_LeaveRecursiveCall();
3046 bool r = operand1 == operand2;
3047 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3052 bool r = operand1 != operand2;
3053 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3058#if PYTHON_VERSION < 0x300
3059 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > unicode()", type1->tp_name);
3060#elif PYTHON_VERSION < 0x360
3061 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > str()", type1->tp_name);
3063 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'str'", type1->tp_name);
3065 return NUITKA_BOOL_EXCEPTION;
3071nuitka_bool RICH_COMPARE_GT_NBOOL_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
3073 if (&PyUnicode_Type == Py_TYPE(operand2)) {
3074 return COMPARE_GT_CBOOL_UNICODE_UNICODE(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3077#if PYTHON_VERSION < 0x300
3078 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3079 return NUITKA_BOOL_EXCEPTION;
3082 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3083 return NUITKA_BOOL_EXCEPTION;
3087 PyTypeObject *type2 = Py_TYPE(operand2);
3089#if PYTHON_VERSION < 0x300
3091 if (&PyUnicode_Type == type2 && !0) {
3093 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
3095 if (frich != NULL) {
3096 PyObject *result = (*frich)(operand1, operand2, Py_GT);
3098 if (result != Py_NotImplemented) {
3099 Py_LeaveRecursiveCall();
3101 if (unlikely(result == NULL)) {
3102 return NUITKA_BOOL_EXCEPTION;
3106 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3112 Py_DECREF_IMMORTAL(result);
3116 cmpfunc fcmp = PyUnicode_Type.tp_compare;
3119 int c = (*fcmp)(operand1, operand2);
3120 c = adjust_tp_compare(c);
3122 Py_LeaveRecursiveCall();
3125 return NUITKA_BOOL_EXCEPTION;
3148 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3152 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3161 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
3162 f = TP_RICHCOMPARE(type2);
3165 PyObject *result = (*f)(operand2, operand1, Py_LT);
3167 if (result != Py_NotImplemented) {
3168 Py_LeaveRecursiveCall();
3170 if (unlikely(result == NULL)) {
3171 return NUITKA_BOOL_EXCEPTION;
3175 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3181 Py_DECREF_IMMORTAL(result);
3185 f = PyUnicode_Type.tp_richcompare;
3187 PyObject *result = (*f)(operand1, operand2, Py_GT);
3189 if (result != Py_NotImplemented) {
3190 Py_LeaveRecursiveCall();
3192 if (unlikely(result == NULL)) {
3193 return NUITKA_BOOL_EXCEPTION;
3197 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3203 Py_DECREF_IMMORTAL(result);
3206 f = TP_RICHCOMPARE(type2);
3208 PyObject *result = (*f)(operand2, operand1, Py_LT);
3210 if (result != Py_NotImplemented) {
3211 Py_LeaveRecursiveCall();
3213 if (unlikely(result == NULL)) {
3214 return NUITKA_BOOL_EXCEPTION;
3218 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3224 Py_DECREF_IMMORTAL(result);
3230 cmpfunc fcmp = PyUnicode_Type.tp_compare;
3231 c = (*fcmp)(operand1, operand2);
3232 }
else if (PyInstance_Check(operand2)) {
3233 cmpfunc fcmp = type2->tp_compare;
3234 c = (*fcmp)(operand1, operand2);
3236 c = try_3way_compare(operand1, operand2);
3240 if (&PyUnicode_Type == type2) {
3241 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3242 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3244 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3245 }
else if (operand1 == Py_None) {
3248 }
else if (operand2 == Py_None) {
3251 }
else if (PyNumber_Check(operand1)) {
3254 if (PyNumber_Check(operand2)) {
3256 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
3257 Py_uintptr_t bb = (Py_uintptr_t)type2;
3259 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3263 }
else if (PyNumber_Check(operand2)) {
3267 int s = strcmp((PYTHON_VERSION < 0x300 ?
"unicode" :
"str"), type2->tp_name);
3275 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
3276 Py_uintptr_t bb = (Py_uintptr_t)type2;
3278 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3283 Py_LeaveRecursiveCall();
3285 if (unlikely(c <= -2)) {
3286 return NUITKA_BOOL_EXCEPTION;
3311 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3315 bool checked_reverse_op =
false;
3318 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
3319 f = TP_RICHCOMPARE(type2);
3322 checked_reverse_op =
true;
3324 PyObject *result = (*f)(operand2, operand1, Py_LT);
3326 if (result != Py_NotImplemented) {
3327 Py_LeaveRecursiveCall();
3329 if (unlikely(result == NULL)) {
3330 return NUITKA_BOOL_EXCEPTION;
3334 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3340 Py_DECREF_IMMORTAL(result);
3344 f = PyUnicode_Type.tp_richcompare;
3347 PyObject *result = (*f)(operand1, operand2, Py_GT);
3349 if (result != Py_NotImplemented) {
3350 Py_LeaveRecursiveCall();
3352 if (unlikely(result == NULL)) {
3353 return NUITKA_BOOL_EXCEPTION;
3357 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3363 Py_DECREF_IMMORTAL(result);
3366 if (checked_reverse_op ==
false) {
3367 f = TP_RICHCOMPARE(type2);
3370 PyObject *result = (*f)(operand2, operand1, Py_LT);
3372 if (result != Py_NotImplemented) {
3373 Py_LeaveRecursiveCall();
3375 if (unlikely(result == NULL)) {
3376 return NUITKA_BOOL_EXCEPTION;
3380 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3386 Py_DECREF_IMMORTAL(result);
3390 Py_LeaveRecursiveCall();
3396 bool r = operand1 == operand2;
3397 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3402 bool r = operand1 != operand2;
3403 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3408#if PYTHON_VERSION < 0x300
3409 PyErr_Format(PyExc_TypeError,
"unorderable types: unicode() > %s()", type2->tp_name);
3410#elif PYTHON_VERSION < 0x360
3411 PyErr_Format(PyExc_TypeError,
"unorderable types: str() > %s()", type2->tp_name);
3413 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'str' and '%s'", type2->tp_name);
3415 return NUITKA_BOOL_EXCEPTION;
3420#if PYTHON_VERSION >= 0x300
3421static PyObject *COMPARE_GT_OBJECT_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
3422 CHECK_OBJECT(operand1);
3423 assert(PyBytes_CheckExact(operand1));
3424 CHECK_OBJECT(operand2);
3425 assert(PyBytes_CheckExact(operand2));
3427 PyBytesObject *a = (PyBytesObject *)operand1;
3428 PyBytesObject *b = (PyBytesObject *)operand2;
3431 if (operand1 == operand2) {
3435 PyObject *result = BOOL_FROM(r);
3436 Py_INCREF_IMMORTAL(result);
3440 Py_ssize_t len_a = Py_SIZE(operand1);
3441 Py_ssize_t len_b = Py_SIZE(operand2);
3443 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
3447 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
3450 c = memcmp(a->ob_sval, b->ob_sval, min_len);
3457 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
3463 PyObject *result = BOOL_FROM(c != 0);
3464 Py_INCREF_IMMORTAL(result);
3468#if PYTHON_VERSION >= 0x300
3470PyObject *RICH_COMPARE_GT_OBJECT_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
3472 if (Py_TYPE(operand1) == &PyBytes_Type) {
3473 return COMPARE_GT_OBJECT_BYTES_BYTES(operand1, operand2);
3476#if PYTHON_VERSION < 0x300
3477 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3481 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3486 PyTypeObject *type1 = Py_TYPE(operand1);
3488#if PYTHON_VERSION < 0x300
3490 if (type1 == &PyBytes_Type && !0) {
3492 richcmpfunc frich = PyBytes_Type.tp_richcompare;
3494 if (frich != NULL) {
3495 PyObject *result = (*frich)(operand1, operand2, Py_GT);
3497 if (result != Py_NotImplemented) {
3498 Py_LeaveRecursiveCall();
3503 Py_DECREF_IMMORTAL(result);
3507 cmpfunc fcmp = NULL;
3510 int c = (*fcmp)(operand1, operand2);
3511 c = adjust_tp_compare(c);
3513 Py_LeaveRecursiveCall();
3539 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3543 PyObject *result = BOOL_FROM(r);
3544 Py_INCREF_IMMORTAL(result);
3552 if (type1 != &PyBytes_Type && 0) {
3553 f = PyBytes_Type.tp_richcompare;
3556 PyObject *result = (*f)(operand2, operand1, Py_LT);
3558 if (result != Py_NotImplemented) {
3559 Py_LeaveRecursiveCall();
3564 Py_DECREF_IMMORTAL(result);
3568 f = TP_RICHCOMPARE(type1);
3570 PyObject *result = (*f)(operand1, operand2, Py_GT);
3572 if (result != Py_NotImplemented) {
3573 Py_LeaveRecursiveCall();
3578 Py_DECREF_IMMORTAL(result);
3581 f = PyBytes_Type.tp_richcompare;
3583 PyObject *result = (*f)(operand2, operand1, Py_LT);
3585 if (result != Py_NotImplemented) {
3586 Py_LeaveRecursiveCall();
3591 Py_DECREF_IMMORTAL(result);
3596 if (PyInstance_Check(operand1)) {
3597 cmpfunc fcmp = type1->tp_compare;
3598 c = (*fcmp)(operand1, operand2);
3600 cmpfunc fcmp = NULL;
3601 c = (*fcmp)(operand1, operand2);
3603 c = try_3way_compare(operand1, operand2);
3607 if (type1 == &PyBytes_Type) {
3608 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3609 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3611 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3612 }
else if (operand1 == Py_None) {
3615 }
else if (operand2 == Py_None) {
3618 }
else if (PyNumber_Check(operand1)) {
3621 if (PyNumber_Check(operand2)) {
3623 Py_uintptr_t aa = (Py_uintptr_t)type1;
3624 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
3626 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3630 }
else if (PyNumber_Check(operand2)) {
3634 int s = strcmp(type1->tp_name,
"bytes");
3642 Py_uintptr_t aa = (Py_uintptr_t)type1;
3643 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
3645 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3650 Py_LeaveRecursiveCall();
3652 if (unlikely(c <= -2)) {
3678 PyObject *result = BOOL_FROM(r);
3679 Py_INCREF_IMMORTAL(result);
3682 bool checked_reverse_op =
false;
3685 if (type1 != &PyBytes_Type && Nuitka_Type_IsSubtype(&PyBytes_Type, type1)) {
3686 f = PyBytes_Type.tp_richcompare;
3689 checked_reverse_op =
true;
3691 PyObject *result = (*f)(operand2, operand1, Py_LT);
3693 if (result != Py_NotImplemented) {
3694 Py_LeaveRecursiveCall();
3699 Py_DECREF_IMMORTAL(result);
3703 f = TP_RICHCOMPARE(type1);
3706 PyObject *result = (*f)(operand1, operand2, Py_GT);
3708 if (result != Py_NotImplemented) {
3709 Py_LeaveRecursiveCall();
3714 Py_DECREF_IMMORTAL(result);
3717 if (checked_reverse_op ==
false) {
3718 f = PyBytes_Type.tp_richcompare;
3721 PyObject *result = (*f)(operand2, operand1, Py_LT);
3723 if (result != Py_NotImplemented) {
3724 Py_LeaveRecursiveCall();
3729 Py_DECREF_IMMORTAL(result);
3733 Py_LeaveRecursiveCall();
3739 bool r = operand1 == operand2;
3740 PyObject *result = BOOL_FROM(r);
3741 Py_INCREF_IMMORTAL(result);
3745 bool r = operand1 != operand2;
3746 PyObject *result = BOOL_FROM(r);
3747 Py_INCREF_IMMORTAL(result);
3751#if PYTHON_VERSION < 0x360
3752 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > bytes()", type1->tp_name);
3754 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'bytes'", type1->tp_name);
3762#if PYTHON_VERSION >= 0x300
3764PyObject *RICH_COMPARE_GT_OBJECT_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
3766 if (&PyBytes_Type == Py_TYPE(operand2)) {
3767 return COMPARE_GT_OBJECT_BYTES_BYTES(operand1, operand2);
3770#if PYTHON_VERSION < 0x300
3771 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3775 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3780 PyTypeObject *type2 = Py_TYPE(operand2);
3782#if PYTHON_VERSION < 0x300
3784 if (&PyBytes_Type == type2 && !0) {
3786 richcmpfunc frich = PyBytes_Type.tp_richcompare;
3788 if (frich != NULL) {
3789 PyObject *result = (*frich)(operand1, operand2, Py_GT);
3791 if (result != Py_NotImplemented) {
3792 Py_LeaveRecursiveCall();
3797 Py_DECREF_IMMORTAL(result);
3801 cmpfunc fcmp = NULL;
3804 int c = (*fcmp)(operand1, operand2);
3805 c = adjust_tp_compare(c);
3807 Py_LeaveRecursiveCall();
3833 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3837 PyObject *result = BOOL_FROM(r);
3838 Py_INCREF_IMMORTAL(result);
3846 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
3847 f = TP_RICHCOMPARE(type2);
3850 PyObject *result = (*f)(operand2, operand1, Py_LT);
3852 if (result != Py_NotImplemented) {
3853 Py_LeaveRecursiveCall();
3858 Py_DECREF_IMMORTAL(result);
3862 f = PyBytes_Type.tp_richcompare;
3864 PyObject *result = (*f)(operand1, operand2, Py_GT);
3866 if (result != Py_NotImplemented) {
3867 Py_LeaveRecursiveCall();
3872 Py_DECREF_IMMORTAL(result);
3875 f = TP_RICHCOMPARE(type2);
3877 PyObject *result = (*f)(operand2, operand1, Py_LT);
3879 if (result != Py_NotImplemented) {
3880 Py_LeaveRecursiveCall();
3885 Py_DECREF_IMMORTAL(result);
3891 cmpfunc fcmp = NULL;
3892 c = (*fcmp)(operand1, operand2);
3893 }
else if (PyInstance_Check(operand2)) {
3894 cmpfunc fcmp = type2->tp_compare;
3895 c = (*fcmp)(operand1, operand2);
3897 c = try_3way_compare(operand1, operand2);
3901 if (&PyBytes_Type == type2) {
3902 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3903 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3905 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3906 }
else if (operand1 == Py_None) {
3909 }
else if (operand2 == Py_None) {
3912 }
else if (PyNumber_Check(operand1)) {
3915 if (PyNumber_Check(operand2)) {
3917 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
3918 Py_uintptr_t bb = (Py_uintptr_t)type2;
3920 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3924 }
else if (PyNumber_Check(operand2)) {
3928 int s = strcmp(
"bytes", type2->tp_name);
3936 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
3937 Py_uintptr_t bb = (Py_uintptr_t)type2;
3939 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3944 Py_LeaveRecursiveCall();
3946 if (unlikely(c <= -2)) {
3972 PyObject *result = BOOL_FROM(r);
3973 Py_INCREF_IMMORTAL(result);
3976 bool checked_reverse_op =
false;
3979 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
3980 f = TP_RICHCOMPARE(type2);
3983 checked_reverse_op =
true;
3985 PyObject *result = (*f)(operand2, operand1, Py_LT);
3987 if (result != Py_NotImplemented) {
3988 Py_LeaveRecursiveCall();
3993 Py_DECREF_IMMORTAL(result);
3997 f = PyBytes_Type.tp_richcompare;
4000 PyObject *result = (*f)(operand1, operand2, Py_GT);
4002 if (result != Py_NotImplemented) {
4003 Py_LeaveRecursiveCall();
4008 Py_DECREF_IMMORTAL(result);
4011 if (checked_reverse_op ==
false) {
4012 f = TP_RICHCOMPARE(type2);
4015 PyObject *result = (*f)(operand2, operand1, Py_LT);
4017 if (result != Py_NotImplemented) {
4018 Py_LeaveRecursiveCall();
4023 Py_DECREF_IMMORTAL(result);
4027 Py_LeaveRecursiveCall();
4033 bool r = operand1 == operand2;
4034 PyObject *result = BOOL_FROM(r);
4035 Py_INCREF_IMMORTAL(result);
4039 bool r = operand1 != operand2;
4040 PyObject *result = BOOL_FROM(r);
4041 Py_INCREF_IMMORTAL(result);
4045#if PYTHON_VERSION < 0x360
4046 PyErr_Format(PyExc_TypeError,
"unorderable types: bytes() > %s()", type2->tp_name);
4048 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'bytes' and '%s'", type2->tp_name);
4056#if PYTHON_VERSION >= 0x300
4057static bool COMPARE_GT_CBOOL_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4058 CHECK_OBJECT(operand1);
4059 assert(PyBytes_CheckExact(operand1));
4060 CHECK_OBJECT(operand2);
4061 assert(PyBytes_CheckExact(operand2));
4063 PyBytesObject *a = (PyBytesObject *)operand1;
4064 PyBytesObject *b = (PyBytesObject *)operand2;
4067 if (operand1 == operand2) {
4076 Py_ssize_t len_a = Py_SIZE(operand1);
4077 Py_ssize_t len_b = Py_SIZE(operand2);
4079 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
4083 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
4086 c = memcmp(a->ob_sval, b->ob_sval, min_len);
4093 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
4099 bool result = c != 0;
4104#if PYTHON_VERSION >= 0x300
4106nuitka_bool RICH_COMPARE_GT_NBOOL_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
4108 if (Py_TYPE(operand1) == &PyBytes_Type) {
4109 return COMPARE_GT_CBOOL_BYTES_BYTES(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4112#if PYTHON_VERSION < 0x300
4113 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4114 return NUITKA_BOOL_EXCEPTION;
4117 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4118 return NUITKA_BOOL_EXCEPTION;
4122 PyTypeObject *type1 = Py_TYPE(operand1);
4124#if PYTHON_VERSION < 0x300
4126 if (type1 == &PyBytes_Type && !0) {
4128 richcmpfunc frich = PyBytes_Type.tp_richcompare;
4130 if (frich != NULL) {
4131 PyObject *result = (*frich)(operand1, operand2, Py_GT);
4133 if (result != Py_NotImplemented) {
4134 Py_LeaveRecursiveCall();
4136 if (unlikely(result == NULL)) {
4137 return NUITKA_BOOL_EXCEPTION;
4141 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4147 Py_DECREF_IMMORTAL(result);
4151 cmpfunc fcmp = NULL;
4154 int c = (*fcmp)(operand1, operand2);
4155 c = adjust_tp_compare(c);
4157 Py_LeaveRecursiveCall();
4160 return NUITKA_BOOL_EXCEPTION;
4183 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4187 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4196 if (type1 != &PyBytes_Type && 0) {
4197 f = PyBytes_Type.tp_richcompare;
4200 PyObject *result = (*f)(operand2, operand1, Py_LT);
4202 if (result != Py_NotImplemented) {
4203 Py_LeaveRecursiveCall();
4205 if (unlikely(result == NULL)) {
4206 return NUITKA_BOOL_EXCEPTION;
4210 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4216 Py_DECREF_IMMORTAL(result);
4220 f = TP_RICHCOMPARE(type1);
4222 PyObject *result = (*f)(operand1, operand2, Py_GT);
4224 if (result != Py_NotImplemented) {
4225 Py_LeaveRecursiveCall();
4227 if (unlikely(result == NULL)) {
4228 return NUITKA_BOOL_EXCEPTION;
4232 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4238 Py_DECREF_IMMORTAL(result);
4241 f = PyBytes_Type.tp_richcompare;
4243 PyObject *result = (*f)(operand2, operand1, Py_LT);
4245 if (result != Py_NotImplemented) {
4246 Py_LeaveRecursiveCall();
4248 if (unlikely(result == NULL)) {
4249 return NUITKA_BOOL_EXCEPTION;
4253 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4259 Py_DECREF_IMMORTAL(result);
4264 if (PyInstance_Check(operand1)) {
4265 cmpfunc fcmp = type1->tp_compare;
4266 c = (*fcmp)(operand1, operand2);
4268 cmpfunc fcmp = NULL;
4269 c = (*fcmp)(operand1, operand2);
4271 c = try_3way_compare(operand1, operand2);
4275 if (type1 == &PyBytes_Type) {
4276 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4277 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4279 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4280 }
else if (operand1 == Py_None) {
4283 }
else if (operand2 == Py_None) {
4286 }
else if (PyNumber_Check(operand1)) {
4289 if (PyNumber_Check(operand2)) {
4291 Py_uintptr_t aa = (Py_uintptr_t)type1;
4292 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
4294 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4298 }
else if (PyNumber_Check(operand2)) {
4302 int s = strcmp(type1->tp_name,
"bytes");
4310 Py_uintptr_t aa = (Py_uintptr_t)type1;
4311 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
4313 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4318 Py_LeaveRecursiveCall();
4320 if (unlikely(c <= -2)) {
4321 return NUITKA_BOOL_EXCEPTION;
4346 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4350 bool checked_reverse_op =
false;
4353 if (type1 != &PyBytes_Type && Nuitka_Type_IsSubtype(&PyBytes_Type, type1)) {
4354 f = PyBytes_Type.tp_richcompare;
4357 checked_reverse_op =
true;
4359 PyObject *result = (*f)(operand2, operand1, Py_LT);
4361 if (result != Py_NotImplemented) {
4362 Py_LeaveRecursiveCall();
4364 if (unlikely(result == NULL)) {
4365 return NUITKA_BOOL_EXCEPTION;
4369 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4375 Py_DECREF_IMMORTAL(result);
4379 f = TP_RICHCOMPARE(type1);
4382 PyObject *result = (*f)(operand1, operand2, Py_GT);
4384 if (result != Py_NotImplemented) {
4385 Py_LeaveRecursiveCall();
4387 if (unlikely(result == NULL)) {
4388 return NUITKA_BOOL_EXCEPTION;
4392 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4398 Py_DECREF_IMMORTAL(result);
4401 if (checked_reverse_op ==
false) {
4402 f = PyBytes_Type.tp_richcompare;
4405 PyObject *result = (*f)(operand2, operand1, Py_LT);
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 Py_LeaveRecursiveCall();
4431 bool r = operand1 == operand2;
4432 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4437 bool r = operand1 != operand2;
4438 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4443#if PYTHON_VERSION < 0x360
4444 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > bytes()", type1->tp_name);
4446 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'bytes'", type1->tp_name);
4448 return NUITKA_BOOL_EXCEPTION;
4454#if PYTHON_VERSION >= 0x300
4456nuitka_bool RICH_COMPARE_GT_NBOOL_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
4458 if (&PyBytes_Type == Py_TYPE(operand2)) {
4459 return COMPARE_GT_CBOOL_BYTES_BYTES(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4462#if PYTHON_VERSION < 0x300
4463 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4464 return NUITKA_BOOL_EXCEPTION;
4467 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4468 return NUITKA_BOOL_EXCEPTION;
4472 PyTypeObject *type2 = Py_TYPE(operand2);
4474#if PYTHON_VERSION < 0x300
4476 if (&PyBytes_Type == type2 && !0) {
4478 richcmpfunc frich = PyBytes_Type.tp_richcompare;
4480 if (frich != NULL) {
4481 PyObject *result = (*frich)(operand1, operand2, Py_GT);
4483 if (result != Py_NotImplemented) {
4484 Py_LeaveRecursiveCall();
4486 if (unlikely(result == NULL)) {
4487 return NUITKA_BOOL_EXCEPTION;
4491 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4497 Py_DECREF_IMMORTAL(result);
4501 cmpfunc fcmp = NULL;
4504 int c = (*fcmp)(operand1, operand2);
4505 c = adjust_tp_compare(c);
4507 Py_LeaveRecursiveCall();
4510 return NUITKA_BOOL_EXCEPTION;
4533 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4537 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4546 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4547 f = TP_RICHCOMPARE(type2);
4550 PyObject *result = (*f)(operand2, operand1, Py_LT);
4552 if (result != Py_NotImplemented) {
4553 Py_LeaveRecursiveCall();
4555 if (unlikely(result == NULL)) {
4556 return NUITKA_BOOL_EXCEPTION;
4560 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4566 Py_DECREF_IMMORTAL(result);
4570 f = PyBytes_Type.tp_richcompare;
4572 PyObject *result = (*f)(operand1, operand2, Py_GT);
4574 if (result != Py_NotImplemented) {
4575 Py_LeaveRecursiveCall();
4577 if (unlikely(result == NULL)) {
4578 return NUITKA_BOOL_EXCEPTION;
4582 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4588 Py_DECREF_IMMORTAL(result);
4591 f = TP_RICHCOMPARE(type2);
4593 PyObject *result = (*f)(operand2, operand1, Py_LT);
4595 if (result != Py_NotImplemented) {
4596 Py_LeaveRecursiveCall();
4598 if (unlikely(result == NULL)) {
4599 return NUITKA_BOOL_EXCEPTION;
4603 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4609 Py_DECREF_IMMORTAL(result);
4615 cmpfunc fcmp = NULL;
4616 c = (*fcmp)(operand1, operand2);
4617 }
else if (PyInstance_Check(operand2)) {
4618 cmpfunc fcmp = type2->tp_compare;
4619 c = (*fcmp)(operand1, operand2);
4621 c = try_3way_compare(operand1, operand2);
4625 if (&PyBytes_Type == type2) {
4626 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4627 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4629 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4630 }
else if (operand1 == Py_None) {
4633 }
else if (operand2 == Py_None) {
4636 }
else if (PyNumber_Check(operand1)) {
4639 if (PyNumber_Check(operand2)) {
4641 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4642 Py_uintptr_t bb = (Py_uintptr_t)type2;
4644 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4648 }
else if (PyNumber_Check(operand2)) {
4652 int s = strcmp(
"bytes", type2->tp_name);
4660 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4661 Py_uintptr_t bb = (Py_uintptr_t)type2;
4663 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4668 Py_LeaveRecursiveCall();
4670 if (unlikely(c <= -2)) {
4671 return NUITKA_BOOL_EXCEPTION;
4696 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4700 bool checked_reverse_op =
false;
4703 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4704 f = TP_RICHCOMPARE(type2);
4707 checked_reverse_op =
true;
4709 PyObject *result = (*f)(operand2, operand1, Py_LT);
4711 if (result != Py_NotImplemented) {
4712 Py_LeaveRecursiveCall();
4714 if (unlikely(result == NULL)) {
4715 return NUITKA_BOOL_EXCEPTION;
4719 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4725 Py_DECREF_IMMORTAL(result);
4729 f = PyBytes_Type.tp_richcompare;
4732 PyObject *result = (*f)(operand1, operand2, Py_GT);
4734 if (result != Py_NotImplemented) {
4735 Py_LeaveRecursiveCall();
4737 if (unlikely(result == NULL)) {
4738 return NUITKA_BOOL_EXCEPTION;
4742 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4748 Py_DECREF_IMMORTAL(result);
4751 if (checked_reverse_op ==
false) {
4752 f = TP_RICHCOMPARE(type2);
4755 PyObject *result = (*f)(operand2, operand1, Py_LT);
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 Py_LeaveRecursiveCall();
4781 bool r = operand1 == operand2;
4782 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4787 bool r = operand1 != operand2;
4788 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4793#if PYTHON_VERSION < 0x360
4794 PyErr_Format(PyExc_TypeError,
"unorderable types: bytes() > %s()", type2->tp_name);
4796 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'bytes' and '%s'", type2->tp_name);
4798 return NUITKA_BOOL_EXCEPTION;
4804#if PYTHON_VERSION < 0x300
4806PyObject *RICH_COMPARE_GT_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
4808 if (Py_TYPE(operand1) == &PyInt_Type) {
4809 return COMPARE_GT_OBJECT_INT_INT(operand1, operand2);
4812#if PYTHON_VERSION < 0x300
4813 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4817 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4822 PyTypeObject *type1 = Py_TYPE(operand1);
4824#if PYTHON_VERSION < 0x300
4826 if (type1 == &PyInt_Type && !0) {
4828 richcmpfunc frich = NULL;
4830 if (frich != NULL) {
4831 PyObject *result = (*frich)(operand1, operand2, Py_GT);
4833 if (result != Py_NotImplemented) {
4834 Py_LeaveRecursiveCall();
4839 Py_DECREF_IMMORTAL(result);
4843 cmpfunc fcmp = PyInt_Type.tp_compare;
4846 int c = (*fcmp)(operand1, operand2);
4847 c = adjust_tp_compare(c);
4849 Py_LeaveRecursiveCall();
4875 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4879 PyObject *result = BOOL_FROM(r);
4880 Py_INCREF_IMMORTAL(result);
4888 if (type1 != &PyInt_Type && 0) {
4892 PyObject *result = (*f)(operand2, operand1, Py_LT);
4894 if (result != Py_NotImplemented) {
4895 Py_LeaveRecursiveCall();
4900 Py_DECREF_IMMORTAL(result);
4904 f = TP_RICHCOMPARE(type1);
4906 PyObject *result = (*f)(operand1, operand2, Py_GT);
4908 if (result != Py_NotImplemented) {
4909 Py_LeaveRecursiveCall();
4914 Py_DECREF_IMMORTAL(result);
4919 PyObject *result = (*f)(operand2, operand1, Py_LT);
4921 if (result != Py_NotImplemented) {
4922 Py_LeaveRecursiveCall();
4927 Py_DECREF_IMMORTAL(result);
4932 if (PyInstance_Check(operand1)) {
4933 cmpfunc fcmp = type1->tp_compare;
4934 c = (*fcmp)(operand1, operand2);
4936 cmpfunc fcmp = PyInt_Type.tp_compare;
4937 c = (*fcmp)(operand1, operand2);
4939 c = try_3way_compare(operand1, operand2);
4943 if (type1 == &PyInt_Type) {
4944 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4945 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4947 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4948 }
else if (operand1 == Py_None) {
4951 }
else if (operand2 == Py_None) {
4954 }
else if (PyNumber_Check(operand1)) {
4957 if (PyNumber_Check(operand2)) {
4959 Py_uintptr_t aa = (Py_uintptr_t)type1;
4960 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
4962 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4966 }
else if (PyNumber_Check(operand2)) {
4970 int s = strcmp(type1->tp_name,
"int");
4978 Py_uintptr_t aa = (Py_uintptr_t)type1;
4979 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
4981 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4986 Py_LeaveRecursiveCall();
4988 if (unlikely(c <= -2)) {
5014 PyObject *result = BOOL_FROM(r);
5015 Py_INCREF_IMMORTAL(result);
5018 bool checked_reverse_op =
false;
5021 if (type1 != &PyInt_Type && Nuitka_Type_IsSubtype(&PyInt_Type, type1)) {
5025 checked_reverse_op =
true;
5027 PyObject *result = (*f)(operand2, operand1, Py_LT);
5029 if (result != Py_NotImplemented) {
5030 Py_LeaveRecursiveCall();
5035 Py_DECREF_IMMORTAL(result);
5039 f = TP_RICHCOMPARE(type1);
5042 PyObject *result = (*f)(operand1, operand2, Py_GT);
5044 if (result != Py_NotImplemented) {
5045 Py_LeaveRecursiveCall();
5050 Py_DECREF_IMMORTAL(result);
5053 if (checked_reverse_op ==
false) {
5057 PyObject *result = (*f)(operand2, operand1, Py_LT);
5059 if (result != Py_NotImplemented) {
5060 Py_LeaveRecursiveCall();
5065 Py_DECREF_IMMORTAL(result);
5069 Py_LeaveRecursiveCall();
5075 bool r = operand1 == operand2;
5076 PyObject *result = BOOL_FROM(r);
5077 Py_INCREF_IMMORTAL(result);
5081 bool r = operand1 != operand2;
5082 PyObject *result = BOOL_FROM(r);
5083 Py_INCREF_IMMORTAL(result);
5087#if PYTHON_VERSION < 0x360
5088 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > int()", type1->tp_name);
5090 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'int'", type1->tp_name);
5098#if PYTHON_VERSION < 0x300
5100PyObject *RICH_COMPARE_GT_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
5102 if (&PyInt_Type == Py_TYPE(operand2)) {
5103 return COMPARE_GT_OBJECT_INT_INT(operand1, operand2);
5106#if PYTHON_VERSION < 0x300
5107 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5111 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5116 PyTypeObject *type2 = Py_TYPE(operand2);
5118#if PYTHON_VERSION < 0x300
5120 if (&PyInt_Type == type2 && !0) {
5122 richcmpfunc frich = NULL;
5124 if (frich != NULL) {
5125 PyObject *result = (*frich)(operand1, operand2, Py_GT);
5127 if (result != Py_NotImplemented) {
5128 Py_LeaveRecursiveCall();
5133 Py_DECREF_IMMORTAL(result);
5137 cmpfunc fcmp = PyInt_Type.tp_compare;
5140 int c = (*fcmp)(operand1, operand2);
5141 c = adjust_tp_compare(c);
5143 Py_LeaveRecursiveCall();
5169 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5173 PyObject *result = BOOL_FROM(r);
5174 Py_INCREF_IMMORTAL(result);
5182 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5183 f = TP_RICHCOMPARE(type2);
5186 PyObject *result = (*f)(operand2, operand1, Py_LT);
5188 if (result != Py_NotImplemented) {
5189 Py_LeaveRecursiveCall();
5194 Py_DECREF_IMMORTAL(result);
5200 PyObject *result = (*f)(operand1, operand2, Py_GT);
5202 if (result != Py_NotImplemented) {
5203 Py_LeaveRecursiveCall();
5208 Py_DECREF_IMMORTAL(result);
5211 f = TP_RICHCOMPARE(type2);
5213 PyObject *result = (*f)(operand2, operand1, Py_LT);
5215 if (result != Py_NotImplemented) {
5216 Py_LeaveRecursiveCall();
5221 Py_DECREF_IMMORTAL(result);
5227 cmpfunc fcmp = PyInt_Type.tp_compare;
5228 c = (*fcmp)(operand1, operand2);
5229 }
else if (PyInstance_Check(operand2)) {
5230 cmpfunc fcmp = type2->tp_compare;
5231 c = (*fcmp)(operand1, operand2);
5233 c = try_3way_compare(operand1, operand2);
5237 if (&PyInt_Type == type2) {
5238 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5239 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5241 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5242 }
else if (operand1 == Py_None) {
5245 }
else if (operand2 == Py_None) {
5248 }
else if (PyNumber_Check(operand1)) {
5251 if (PyNumber_Check(operand2)) {
5253 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5254 Py_uintptr_t bb = (Py_uintptr_t)type2;
5256 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5260 }
else if (PyNumber_Check(operand2)) {
5264 int s = strcmp(
"int", type2->tp_name);
5272 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5273 Py_uintptr_t bb = (Py_uintptr_t)type2;
5275 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5280 Py_LeaveRecursiveCall();
5282 if (unlikely(c <= -2)) {
5308 PyObject *result = BOOL_FROM(r);
5309 Py_INCREF_IMMORTAL(result);
5312 bool checked_reverse_op =
false;
5315 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5316 f = TP_RICHCOMPARE(type2);
5319 checked_reverse_op =
true;
5321 PyObject *result = (*f)(operand2, operand1, Py_LT);
5323 if (result != Py_NotImplemented) {
5324 Py_LeaveRecursiveCall();
5329 Py_DECREF_IMMORTAL(result);
5336 PyObject *result = (*f)(operand1, operand2, Py_GT);
5338 if (result != Py_NotImplemented) {
5339 Py_LeaveRecursiveCall();
5344 Py_DECREF_IMMORTAL(result);
5347 if (checked_reverse_op ==
false) {
5348 f = TP_RICHCOMPARE(type2);
5351 PyObject *result = (*f)(operand2, operand1, Py_LT);
5353 if (result != Py_NotImplemented) {
5354 Py_LeaveRecursiveCall();
5359 Py_DECREF_IMMORTAL(result);
5363 Py_LeaveRecursiveCall();
5369 bool r = operand1 == operand2;
5370 PyObject *result = BOOL_FROM(r);
5371 Py_INCREF_IMMORTAL(result);
5375 bool r = operand1 != operand2;
5376 PyObject *result = BOOL_FROM(r);
5377 Py_INCREF_IMMORTAL(result);
5381#if PYTHON_VERSION < 0x360
5382 PyErr_Format(PyExc_TypeError,
"unorderable types: int() > %s()", type2->tp_name);
5384 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'int' and '%s'", type2->tp_name);
5392#if PYTHON_VERSION < 0x300
5394nuitka_bool RICH_COMPARE_GT_NBOOL_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
5396 if (Py_TYPE(operand1) == &PyInt_Type) {
5397 return COMPARE_GT_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5400#if PYTHON_VERSION < 0x300
5401 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5402 return NUITKA_BOOL_EXCEPTION;
5405 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5406 return NUITKA_BOOL_EXCEPTION;
5410 PyTypeObject *type1 = Py_TYPE(operand1);
5412#if PYTHON_VERSION < 0x300
5414 if (type1 == &PyInt_Type && !0) {
5416 richcmpfunc frich = NULL;
5418 if (frich != NULL) {
5419 PyObject *result = (*frich)(operand1, operand2, Py_GT);
5421 if (result != Py_NotImplemented) {
5422 Py_LeaveRecursiveCall();
5424 if (unlikely(result == NULL)) {
5425 return NUITKA_BOOL_EXCEPTION;
5429 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5435 Py_DECREF_IMMORTAL(result);
5439 cmpfunc fcmp = PyInt_Type.tp_compare;
5442 int c = (*fcmp)(operand1, operand2);
5443 c = adjust_tp_compare(c);
5445 Py_LeaveRecursiveCall();
5448 return NUITKA_BOOL_EXCEPTION;
5471 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5475 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5484 if (type1 != &PyInt_Type && 0) {
5488 PyObject *result = (*f)(operand2, operand1, Py_LT);
5490 if (result != Py_NotImplemented) {
5491 Py_LeaveRecursiveCall();
5493 if (unlikely(result == NULL)) {
5494 return NUITKA_BOOL_EXCEPTION;
5498 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5504 Py_DECREF_IMMORTAL(result);
5508 f = TP_RICHCOMPARE(type1);
5510 PyObject *result = (*f)(operand1, operand2, Py_GT);
5512 if (result != Py_NotImplemented) {
5513 Py_LeaveRecursiveCall();
5515 if (unlikely(result == NULL)) {
5516 return NUITKA_BOOL_EXCEPTION;
5520 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5526 Py_DECREF_IMMORTAL(result);
5531 PyObject *result = (*f)(operand2, operand1, Py_LT);
5533 if (result != Py_NotImplemented) {
5534 Py_LeaveRecursiveCall();
5536 if (unlikely(result == NULL)) {
5537 return NUITKA_BOOL_EXCEPTION;
5541 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5547 Py_DECREF_IMMORTAL(result);
5552 if (PyInstance_Check(operand1)) {
5553 cmpfunc fcmp = type1->tp_compare;
5554 c = (*fcmp)(operand1, operand2);
5556 cmpfunc fcmp = PyInt_Type.tp_compare;
5557 c = (*fcmp)(operand1, operand2);
5559 c = try_3way_compare(operand1, operand2);
5563 if (type1 == &PyInt_Type) {
5564 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5565 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5567 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5568 }
else if (operand1 == Py_None) {
5571 }
else if (operand2 == Py_None) {
5574 }
else if (PyNumber_Check(operand1)) {
5577 if (PyNumber_Check(operand2)) {
5579 Py_uintptr_t aa = (Py_uintptr_t)type1;
5580 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5582 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5586 }
else if (PyNumber_Check(operand2)) {
5590 int s = strcmp(type1->tp_name,
"int");
5598 Py_uintptr_t aa = (Py_uintptr_t)type1;
5599 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5601 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5606 Py_LeaveRecursiveCall();
5608 if (unlikely(c <= -2)) {
5609 return NUITKA_BOOL_EXCEPTION;
5634 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5638 bool checked_reverse_op =
false;
5641 if (type1 != &PyInt_Type && Nuitka_Type_IsSubtype(&PyInt_Type, type1)) {
5645 checked_reverse_op =
true;
5647 PyObject *result = (*f)(operand2, operand1, Py_LT);
5649 if (result != Py_NotImplemented) {
5650 Py_LeaveRecursiveCall();
5652 if (unlikely(result == NULL)) {
5653 return NUITKA_BOOL_EXCEPTION;
5657 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5663 Py_DECREF_IMMORTAL(result);
5667 f = TP_RICHCOMPARE(type1);
5670 PyObject *result = (*f)(operand1, operand2, Py_GT);
5672 if (result != Py_NotImplemented) {
5673 Py_LeaveRecursiveCall();
5675 if (unlikely(result == NULL)) {
5676 return NUITKA_BOOL_EXCEPTION;
5680 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5686 Py_DECREF_IMMORTAL(result);
5689 if (checked_reverse_op ==
false) {
5693 PyObject *result = (*f)(operand2, operand1, Py_LT);
5695 if (result != Py_NotImplemented) {
5696 Py_LeaveRecursiveCall();
5698 if (unlikely(result == NULL)) {
5699 return NUITKA_BOOL_EXCEPTION;
5703 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5709 Py_DECREF_IMMORTAL(result);
5713 Py_LeaveRecursiveCall();
5719 bool r = operand1 == operand2;
5720 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5725 bool r = operand1 != operand2;
5726 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5731#if PYTHON_VERSION < 0x360
5732 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > int()", type1->tp_name);
5734 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'int'", type1->tp_name);
5736 return NUITKA_BOOL_EXCEPTION;
5742#if PYTHON_VERSION < 0x300
5744nuitka_bool RICH_COMPARE_GT_NBOOL_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
5746 if (&PyInt_Type == Py_TYPE(operand2)) {
5747 return COMPARE_GT_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5750#if PYTHON_VERSION < 0x300
5751 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5752 return NUITKA_BOOL_EXCEPTION;
5755 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5756 return NUITKA_BOOL_EXCEPTION;
5760 PyTypeObject *type2 = Py_TYPE(operand2);
5762#if PYTHON_VERSION < 0x300
5764 if (&PyInt_Type == type2 && !0) {
5766 richcmpfunc frich = NULL;
5768 if (frich != NULL) {
5769 PyObject *result = (*frich)(operand1, operand2, Py_GT);
5771 if (result != Py_NotImplemented) {
5772 Py_LeaveRecursiveCall();
5774 if (unlikely(result == NULL)) {
5775 return NUITKA_BOOL_EXCEPTION;
5779 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5785 Py_DECREF_IMMORTAL(result);
5789 cmpfunc fcmp = PyInt_Type.tp_compare;
5792 int c = (*fcmp)(operand1, operand2);
5793 c = adjust_tp_compare(c);
5795 Py_LeaveRecursiveCall();
5798 return NUITKA_BOOL_EXCEPTION;
5821 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5825 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5834 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5835 f = TP_RICHCOMPARE(type2);
5838 PyObject *result = (*f)(operand2, operand1, Py_LT);
5840 if (result != Py_NotImplemented) {
5841 Py_LeaveRecursiveCall();
5843 if (unlikely(result == NULL)) {
5844 return NUITKA_BOOL_EXCEPTION;
5848 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5854 Py_DECREF_IMMORTAL(result);
5860 PyObject *result = (*f)(operand1, operand2, Py_GT);
5862 if (result != Py_NotImplemented) {
5863 Py_LeaveRecursiveCall();
5865 if (unlikely(result == NULL)) {
5866 return NUITKA_BOOL_EXCEPTION;
5870 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5876 Py_DECREF_IMMORTAL(result);
5879 f = TP_RICHCOMPARE(type2);
5881 PyObject *result = (*f)(operand2, operand1, Py_LT);
5883 if (result != Py_NotImplemented) {
5884 Py_LeaveRecursiveCall();
5886 if (unlikely(result == NULL)) {
5887 return NUITKA_BOOL_EXCEPTION;
5891 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5897 Py_DECREF_IMMORTAL(result);
5903 cmpfunc fcmp = PyInt_Type.tp_compare;
5904 c = (*fcmp)(operand1, operand2);
5905 }
else if (PyInstance_Check(operand2)) {
5906 cmpfunc fcmp = type2->tp_compare;
5907 c = (*fcmp)(operand1, operand2);
5909 c = try_3way_compare(operand1, operand2);
5913 if (&PyInt_Type == type2) {
5914 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5915 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5917 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5918 }
else if (operand1 == Py_None) {
5921 }
else if (operand2 == Py_None) {
5924 }
else if (PyNumber_Check(operand1)) {
5927 if (PyNumber_Check(operand2)) {
5929 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5930 Py_uintptr_t bb = (Py_uintptr_t)type2;
5932 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5936 }
else if (PyNumber_Check(operand2)) {
5940 int s = strcmp(
"int", type2->tp_name);
5948 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5949 Py_uintptr_t bb = (Py_uintptr_t)type2;
5951 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5956 Py_LeaveRecursiveCall();
5958 if (unlikely(c <= -2)) {
5959 return NUITKA_BOOL_EXCEPTION;
5984 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5988 bool checked_reverse_op =
false;
5991 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5992 f = TP_RICHCOMPARE(type2);
5995 checked_reverse_op =
true;
5997 PyObject *result = (*f)(operand2, operand1, Py_LT);
5999 if (result != Py_NotImplemented) {
6000 Py_LeaveRecursiveCall();
6002 if (unlikely(result == NULL)) {
6003 return NUITKA_BOOL_EXCEPTION;
6007 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6013 Py_DECREF_IMMORTAL(result);
6020 PyObject *result = (*f)(operand1, operand2, Py_GT);
6022 if (result != Py_NotImplemented) {
6023 Py_LeaveRecursiveCall();
6025 if (unlikely(result == NULL)) {
6026 return NUITKA_BOOL_EXCEPTION;
6030 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6036 Py_DECREF_IMMORTAL(result);
6039 if (checked_reverse_op ==
false) {
6040 f = TP_RICHCOMPARE(type2);
6043 PyObject *result = (*f)(operand2, operand1, Py_LT);
6045 if (result != Py_NotImplemented) {
6046 Py_LeaveRecursiveCall();
6048 if (unlikely(result == NULL)) {
6049 return NUITKA_BOOL_EXCEPTION;
6053 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6059 Py_DECREF_IMMORTAL(result);
6063 Py_LeaveRecursiveCall();
6069 bool r = operand1 == operand2;
6070 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6075 bool r = operand1 != operand2;
6076 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6081#if PYTHON_VERSION < 0x360
6082 PyErr_Format(PyExc_TypeError,
"unorderable types: int() > %s()", type2->tp_name);
6084 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'int' and '%s'", type2->tp_name);
6086 return NUITKA_BOOL_EXCEPTION;
6092static PyObject *COMPARE_GT_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6093 CHECK_OBJECT(operand1);
6094 assert(PyLong_CheckExact(operand1));
6095 CHECK_OBJECT(operand2);
6096 assert(PyLong_CheckExact(operand2));
6098 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
6100 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
6104 if (operand1_long_object == operand2_long_object) {
6106 }
else if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
6107 Nuitka_LongGetSignedDigitSize(operand2_long_object)) {
6108 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - Nuitka_LongGetSignedDigitSize(operand2_long_object) >
6111 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
6114 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] !=
6115 Nuitka_LongGetDigitPointer(operand2_long_object)[i]) {
6116 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] >
6117 Nuitka_LongGetDigitPointer(operand2_long_object)[i];
6118 if (Nuitka_LongIsNegative(operand1_long_object)) {
6127 PyObject *result = BOOL_FROM(r);
6128 Py_INCREF_IMMORTAL(result);
6132PyObject *RICH_COMPARE_GT_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
6134 if (Py_TYPE(operand1) == &PyLong_Type) {
6135 return COMPARE_GT_OBJECT_LONG_LONG(operand1, operand2);
6138#if PYTHON_VERSION < 0x300
6139 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6143 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6148 PyTypeObject *type1 = Py_TYPE(operand1);
6150#if PYTHON_VERSION < 0x300
6152 if (type1 == &PyLong_Type && !0) {
6154 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6156 if (frich != NULL) {
6157 PyObject *result = (*frich)(operand1, operand2, Py_GT);
6159 if (result != Py_NotImplemented) {
6160 Py_LeaveRecursiveCall();
6165 Py_DECREF_IMMORTAL(result);
6169 cmpfunc fcmp = PyLong_Type.tp_compare;
6172 int c = (*fcmp)(operand1, operand2);
6173 c = adjust_tp_compare(c);
6175 Py_LeaveRecursiveCall();
6201 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6205 PyObject *result = BOOL_FROM(r);
6206 Py_INCREF_IMMORTAL(result);
6214 if (type1 != &PyLong_Type && 0) {
6215 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6218 PyObject *result = (*f)(operand2, operand1, Py_LT);
6220 if (result != Py_NotImplemented) {
6221 Py_LeaveRecursiveCall();
6226 Py_DECREF_IMMORTAL(result);
6230 f = TP_RICHCOMPARE(type1);
6232 PyObject *result = (*f)(operand1, operand2, Py_GT);
6234 if (result != Py_NotImplemented) {
6235 Py_LeaveRecursiveCall();
6240 Py_DECREF_IMMORTAL(result);
6243 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6245 PyObject *result = (*f)(operand2, operand1, Py_LT);
6247 if (result != Py_NotImplemented) {
6248 Py_LeaveRecursiveCall();
6253 Py_DECREF_IMMORTAL(result);
6258 if (PyInstance_Check(operand1)) {
6259 cmpfunc fcmp = type1->tp_compare;
6260 c = (*fcmp)(operand1, operand2);
6262 cmpfunc fcmp = PyLong_Type.tp_compare;
6263 c = (*fcmp)(operand1, operand2);
6265 c = try_3way_compare(operand1, operand2);
6269 if (type1 == &PyLong_Type) {
6270 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6271 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6273 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6274 }
else if (operand1 == Py_None) {
6277 }
else if (operand2 == Py_None) {
6280 }
else if (PyNumber_Check(operand1)) {
6283 if (PyNumber_Check(operand2)) {
6285 Py_uintptr_t aa = (Py_uintptr_t)type1;
6286 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6288 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6292 }
else if (PyNumber_Check(operand2)) {
6296 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"long" :
"int"));
6304 Py_uintptr_t aa = (Py_uintptr_t)type1;
6305 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6307 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6312 Py_LeaveRecursiveCall();
6314 if (unlikely(c <= -2)) {
6340 PyObject *result = BOOL_FROM(r);
6341 Py_INCREF_IMMORTAL(result);
6344 bool checked_reverse_op =
false;
6347 if (type1 != &PyLong_Type && Nuitka_Type_IsSubtype(&PyLong_Type, type1)) {
6348 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6351 checked_reverse_op =
true;
6353 PyObject *result = (*f)(operand2, operand1, Py_LT);
6355 if (result != Py_NotImplemented) {
6356 Py_LeaveRecursiveCall();
6361 Py_DECREF_IMMORTAL(result);
6365 f = TP_RICHCOMPARE(type1);
6368 PyObject *result = (*f)(operand1, operand2, Py_GT);
6370 if (result != Py_NotImplemented) {
6371 Py_LeaveRecursiveCall();
6376 Py_DECREF_IMMORTAL(result);
6379 if (checked_reverse_op ==
false) {
6380 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6383 PyObject *result = (*f)(operand2, operand1, Py_LT);
6385 if (result != Py_NotImplemented) {
6386 Py_LeaveRecursiveCall();
6391 Py_DECREF_IMMORTAL(result);
6395 Py_LeaveRecursiveCall();
6401 bool r = operand1 == operand2;
6402 PyObject *result = BOOL_FROM(r);
6403 Py_INCREF_IMMORTAL(result);
6407 bool r = operand1 != operand2;
6408 PyObject *result = BOOL_FROM(r);
6409 Py_INCREF_IMMORTAL(result);
6413#if PYTHON_VERSION < 0x300
6414 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > long()", type1->tp_name);
6415#elif PYTHON_VERSION < 0x360
6416 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > int()", type1->tp_name);
6418 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'int'", type1->tp_name);
6426PyObject *RICH_COMPARE_GT_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
6428 if (&PyLong_Type == Py_TYPE(operand2)) {
6429 return COMPARE_GT_OBJECT_LONG_LONG(operand1, operand2);
6432#if PYTHON_VERSION < 0x300
6433 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6437 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6442 PyTypeObject *type2 = Py_TYPE(operand2);
6444#if PYTHON_VERSION < 0x300
6446 if (&PyLong_Type == type2 && !0) {
6448 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6450 if (frich != NULL) {
6451 PyObject *result = (*frich)(operand1, operand2, Py_GT);
6453 if (result != Py_NotImplemented) {
6454 Py_LeaveRecursiveCall();
6459 Py_DECREF_IMMORTAL(result);
6463 cmpfunc fcmp = PyLong_Type.tp_compare;
6466 int c = (*fcmp)(operand1, operand2);
6467 c = adjust_tp_compare(c);
6469 Py_LeaveRecursiveCall();
6495 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6499 PyObject *result = BOOL_FROM(r);
6500 Py_INCREF_IMMORTAL(result);
6508 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
6509 f = TP_RICHCOMPARE(type2);
6512 PyObject *result = (*f)(operand2, operand1, Py_LT);
6514 if (result != Py_NotImplemented) {
6515 Py_LeaveRecursiveCall();
6520 Py_DECREF_IMMORTAL(result);
6524 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6526 PyObject *result = (*f)(operand1, operand2, Py_GT);
6528 if (result != Py_NotImplemented) {
6529 Py_LeaveRecursiveCall();
6534 Py_DECREF_IMMORTAL(result);
6537 f = TP_RICHCOMPARE(type2);
6539 PyObject *result = (*f)(operand2, operand1, Py_LT);
6541 if (result != Py_NotImplemented) {
6542 Py_LeaveRecursiveCall();
6547 Py_DECREF_IMMORTAL(result);
6553 cmpfunc fcmp = PyLong_Type.tp_compare;
6554 c = (*fcmp)(operand1, operand2);
6555 }
else if (PyInstance_Check(operand2)) {
6556 cmpfunc fcmp = type2->tp_compare;
6557 c = (*fcmp)(operand1, operand2);
6559 c = try_3way_compare(operand1, operand2);
6563 if (&PyLong_Type == type2) {
6564 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6565 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6567 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6568 }
else if (operand1 == Py_None) {
6571 }
else if (operand2 == Py_None) {
6574 }
else if (PyNumber_Check(operand1)) {
6577 if (PyNumber_Check(operand2)) {
6579 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
6580 Py_uintptr_t bb = (Py_uintptr_t)type2;
6582 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6586 }
else if (PyNumber_Check(operand2)) {
6590 int s = strcmp((PYTHON_VERSION < 0x300 ?
"long" :
"int"), type2->tp_name);
6598 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
6599 Py_uintptr_t bb = (Py_uintptr_t)type2;
6601 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6606 Py_LeaveRecursiveCall();
6608 if (unlikely(c <= -2)) {
6634 PyObject *result = BOOL_FROM(r);
6635 Py_INCREF_IMMORTAL(result);
6638 bool checked_reverse_op =
false;
6641 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
6642 f = TP_RICHCOMPARE(type2);
6645 checked_reverse_op =
true;
6647 PyObject *result = (*f)(operand2, operand1, Py_LT);
6649 if (result != Py_NotImplemented) {
6650 Py_LeaveRecursiveCall();
6655 Py_DECREF_IMMORTAL(result);
6659 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6662 PyObject *result = (*f)(operand1, operand2, Py_GT);
6664 if (result != Py_NotImplemented) {
6665 Py_LeaveRecursiveCall();
6670 Py_DECREF_IMMORTAL(result);
6673 if (checked_reverse_op ==
false) {
6674 f = TP_RICHCOMPARE(type2);
6677 PyObject *result = (*f)(operand2, operand1, Py_LT);
6679 if (result != Py_NotImplemented) {
6680 Py_LeaveRecursiveCall();
6685 Py_DECREF_IMMORTAL(result);
6689 Py_LeaveRecursiveCall();
6695 bool r = operand1 == operand2;
6696 PyObject *result = BOOL_FROM(r);
6697 Py_INCREF_IMMORTAL(result);
6701 bool r = operand1 != operand2;
6702 PyObject *result = BOOL_FROM(r);
6703 Py_INCREF_IMMORTAL(result);
6707#if PYTHON_VERSION < 0x300
6708 PyErr_Format(PyExc_TypeError,
"unorderable types: long() > %s()", type2->tp_name);
6709#elif PYTHON_VERSION < 0x360
6710 PyErr_Format(PyExc_TypeError,
"unorderable types: int() > %s()", type2->tp_name);
6712 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'int' and '%s'", type2->tp_name);
6719static bool COMPARE_GT_CBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6720 CHECK_OBJECT(operand1);
6721 assert(PyLong_CheckExact(operand1));
6722 CHECK_OBJECT(operand2);
6723 assert(PyLong_CheckExact(operand2));
6725 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
6727 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
6731 if (operand1_long_object == operand2_long_object) {
6733 }
else if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
6734 Nuitka_LongGetSignedDigitSize(operand2_long_object)) {
6735 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - Nuitka_LongGetSignedDigitSize(operand2_long_object) >
6738 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
6741 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] !=
6742 Nuitka_LongGetDigitPointer(operand2_long_object)[i]) {
6743 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] >
6744 Nuitka_LongGetDigitPointer(operand2_long_object)[i];
6745 if (Nuitka_LongIsNegative(operand1_long_object)) {
6759nuitka_bool RICH_COMPARE_GT_NBOOL_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
6761 if (Py_TYPE(operand1) == &PyLong_Type) {
6762 return COMPARE_GT_CBOOL_LONG_LONG(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6765#if PYTHON_VERSION < 0x300
6766 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6767 return NUITKA_BOOL_EXCEPTION;
6770 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6771 return NUITKA_BOOL_EXCEPTION;
6775 PyTypeObject *type1 = Py_TYPE(operand1);
6777#if PYTHON_VERSION < 0x300
6779 if (type1 == &PyLong_Type && !0) {
6781 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6783 if (frich != NULL) {
6784 PyObject *result = (*frich)(operand1, operand2, Py_GT);
6786 if (result != Py_NotImplemented) {
6787 Py_LeaveRecursiveCall();
6789 if (unlikely(result == NULL)) {
6790 return NUITKA_BOOL_EXCEPTION;
6794 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6800 Py_DECREF_IMMORTAL(result);
6804 cmpfunc fcmp = PyLong_Type.tp_compare;
6807 int c = (*fcmp)(operand1, operand2);
6808 c = adjust_tp_compare(c);
6810 Py_LeaveRecursiveCall();
6813 return NUITKA_BOOL_EXCEPTION;
6836 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6840 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6849 if (type1 != &PyLong_Type && 0) {
6850 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6853 PyObject *result = (*f)(operand2, operand1, Py_LT);
6855 if (result != Py_NotImplemented) {
6856 Py_LeaveRecursiveCall();
6858 if (unlikely(result == NULL)) {
6859 return NUITKA_BOOL_EXCEPTION;
6863 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6869 Py_DECREF_IMMORTAL(result);
6873 f = TP_RICHCOMPARE(type1);
6875 PyObject *result = (*f)(operand1, operand2, Py_GT);
6877 if (result != Py_NotImplemented) {
6878 Py_LeaveRecursiveCall();
6880 if (unlikely(result == NULL)) {
6881 return NUITKA_BOOL_EXCEPTION;
6885 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6891 Py_DECREF_IMMORTAL(result);
6894 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6896 PyObject *result = (*f)(operand2, operand1, Py_LT);
6898 if (result != Py_NotImplemented) {
6899 Py_LeaveRecursiveCall();
6901 if (unlikely(result == NULL)) {
6902 return NUITKA_BOOL_EXCEPTION;
6906 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6912 Py_DECREF_IMMORTAL(result);
6917 if (PyInstance_Check(operand1)) {
6918 cmpfunc fcmp = type1->tp_compare;
6919 c = (*fcmp)(operand1, operand2);
6921 cmpfunc fcmp = PyLong_Type.tp_compare;
6922 c = (*fcmp)(operand1, operand2);
6924 c = try_3way_compare(operand1, operand2);
6928 if (type1 == &PyLong_Type) {
6929 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6930 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6932 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6933 }
else if (operand1 == Py_None) {
6936 }
else if (operand2 == Py_None) {
6939 }
else if (PyNumber_Check(operand1)) {
6942 if (PyNumber_Check(operand2)) {
6944 Py_uintptr_t aa = (Py_uintptr_t)type1;
6945 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6947 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6951 }
else if (PyNumber_Check(operand2)) {
6955 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"long" :
"int"));
6963 Py_uintptr_t aa = (Py_uintptr_t)type1;
6964 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6966 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6971 Py_LeaveRecursiveCall();
6973 if (unlikely(c <= -2)) {
6974 return NUITKA_BOOL_EXCEPTION;
6999 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7003 bool checked_reverse_op =
false;
7006 if (type1 != &PyLong_Type && Nuitka_Type_IsSubtype(&PyLong_Type, type1)) {
7007 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7010 checked_reverse_op =
true;
7012 PyObject *result = (*f)(operand2, operand1, Py_LT);
7014 if (result != Py_NotImplemented) {
7015 Py_LeaveRecursiveCall();
7017 if (unlikely(result == NULL)) {
7018 return NUITKA_BOOL_EXCEPTION;
7022 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7028 Py_DECREF_IMMORTAL(result);
7032 f = TP_RICHCOMPARE(type1);
7035 PyObject *result = (*f)(operand1, operand2, Py_GT);
7037 if (result != Py_NotImplemented) {
7038 Py_LeaveRecursiveCall();
7040 if (unlikely(result == NULL)) {
7041 return NUITKA_BOOL_EXCEPTION;
7045 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7051 Py_DECREF_IMMORTAL(result);
7054 if (checked_reverse_op ==
false) {
7055 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7058 PyObject *result = (*f)(operand2, operand1, Py_LT);
7060 if (result != Py_NotImplemented) {
7061 Py_LeaveRecursiveCall();
7063 if (unlikely(result == NULL)) {
7064 return NUITKA_BOOL_EXCEPTION;
7068 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7074 Py_DECREF_IMMORTAL(result);
7078 Py_LeaveRecursiveCall();
7084 bool r = operand1 == operand2;
7085 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7090 bool r = operand1 != operand2;
7091 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7096#if PYTHON_VERSION < 0x300
7097 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > long()", type1->tp_name);
7098#elif PYTHON_VERSION < 0x360
7099 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > int()", type1->tp_name);
7101 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'int'", type1->tp_name);
7103 return NUITKA_BOOL_EXCEPTION;
7109nuitka_bool RICH_COMPARE_GT_NBOOL_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
7111 if (&PyLong_Type == Py_TYPE(operand2)) {
7112 return COMPARE_GT_CBOOL_LONG_LONG(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7115#if PYTHON_VERSION < 0x300
7116 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7117 return NUITKA_BOOL_EXCEPTION;
7120 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7121 return NUITKA_BOOL_EXCEPTION;
7125 PyTypeObject *type2 = Py_TYPE(operand2);
7127#if PYTHON_VERSION < 0x300
7129 if (&PyLong_Type == type2 && !0) {
7131 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7133 if (frich != NULL) {
7134 PyObject *result = (*frich)(operand1, operand2, Py_GT);
7136 if (result != Py_NotImplemented) {
7137 Py_LeaveRecursiveCall();
7139 if (unlikely(result == NULL)) {
7140 return NUITKA_BOOL_EXCEPTION;
7144 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7150 Py_DECREF_IMMORTAL(result);
7154 cmpfunc fcmp = PyLong_Type.tp_compare;
7157 int c = (*fcmp)(operand1, operand2);
7158 c = adjust_tp_compare(c);
7160 Py_LeaveRecursiveCall();
7163 return NUITKA_BOOL_EXCEPTION;
7186 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7190 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7199 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
7200 f = TP_RICHCOMPARE(type2);
7203 PyObject *result = (*f)(operand2, operand1, Py_LT);
7205 if (result != Py_NotImplemented) {
7206 Py_LeaveRecursiveCall();
7208 if (unlikely(result == NULL)) {
7209 return NUITKA_BOOL_EXCEPTION;
7213 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7219 Py_DECREF_IMMORTAL(result);
7223 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7225 PyObject *result = (*f)(operand1, operand2, Py_GT);
7227 if (result != Py_NotImplemented) {
7228 Py_LeaveRecursiveCall();
7230 if (unlikely(result == NULL)) {
7231 return NUITKA_BOOL_EXCEPTION;
7235 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7241 Py_DECREF_IMMORTAL(result);
7244 f = TP_RICHCOMPARE(type2);
7246 PyObject *result = (*f)(operand2, operand1, Py_LT);
7248 if (result != Py_NotImplemented) {
7249 Py_LeaveRecursiveCall();
7251 if (unlikely(result == NULL)) {
7252 return NUITKA_BOOL_EXCEPTION;
7256 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7262 Py_DECREF_IMMORTAL(result);
7268 cmpfunc fcmp = PyLong_Type.tp_compare;
7269 c = (*fcmp)(operand1, operand2);
7270 }
else if (PyInstance_Check(operand2)) {
7271 cmpfunc fcmp = type2->tp_compare;
7272 c = (*fcmp)(operand1, operand2);
7274 c = try_3way_compare(operand1, operand2);
7278 if (&PyLong_Type == type2) {
7279 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7280 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7282 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7283 }
else if (operand1 == Py_None) {
7286 }
else if (operand2 == Py_None) {
7289 }
else if (PyNumber_Check(operand1)) {
7292 if (PyNumber_Check(operand2)) {
7294 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
7295 Py_uintptr_t bb = (Py_uintptr_t)type2;
7297 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7301 }
else if (PyNumber_Check(operand2)) {
7305 int s = strcmp((PYTHON_VERSION < 0x300 ?
"long" :
"int"), type2->tp_name);
7313 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
7314 Py_uintptr_t bb = (Py_uintptr_t)type2;
7316 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7321 Py_LeaveRecursiveCall();
7323 if (unlikely(c <= -2)) {
7324 return NUITKA_BOOL_EXCEPTION;
7349 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7353 bool checked_reverse_op =
false;
7356 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
7357 f = TP_RICHCOMPARE(type2);
7360 checked_reverse_op =
true;
7362 PyObject *result = (*f)(operand2, operand1, Py_LT);
7364 if (result != Py_NotImplemented) {
7365 Py_LeaveRecursiveCall();
7367 if (unlikely(result == NULL)) {
7368 return NUITKA_BOOL_EXCEPTION;
7372 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7378 Py_DECREF_IMMORTAL(result);
7382 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7385 PyObject *result = (*f)(operand1, operand2, Py_GT);
7387 if (result != Py_NotImplemented) {
7388 Py_LeaveRecursiveCall();
7390 if (unlikely(result == NULL)) {
7391 return NUITKA_BOOL_EXCEPTION;
7395 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7401 Py_DECREF_IMMORTAL(result);
7404 if (checked_reverse_op ==
false) {
7405 f = TP_RICHCOMPARE(type2);
7408 PyObject *result = (*f)(operand2, operand1, Py_LT);
7410 if (result != Py_NotImplemented) {
7411 Py_LeaveRecursiveCall();
7413 if (unlikely(result == NULL)) {
7414 return NUITKA_BOOL_EXCEPTION;
7418 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7424 Py_DECREF_IMMORTAL(result);
7428 Py_LeaveRecursiveCall();
7434 bool r = operand1 == operand2;
7435 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7440 bool r = operand1 != operand2;
7441 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7446#if PYTHON_VERSION < 0x300
7447 PyErr_Format(PyExc_TypeError,
"unorderable types: long() > %s()", type2->tp_name);
7448#elif PYTHON_VERSION < 0x360
7449 PyErr_Format(PyExc_TypeError,
"unorderable types: int() > %s()", type2->tp_name);
7451 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'int' and '%s'", type2->tp_name);
7453 return NUITKA_BOOL_EXCEPTION;
7458static PyObject *COMPARE_GT_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
7459 CHECK_OBJECT(operand1);
7460 assert(PyFloat_CheckExact(operand1));
7461 CHECK_OBJECT(operand2);
7462 assert(PyFloat_CheckExact(operand2));
7464 const double a = PyFloat_AS_DOUBLE(operand1);
7465 const double b = PyFloat_AS_DOUBLE(operand2);
7470 PyObject *result = BOOL_FROM(r);
7471 Py_INCREF_IMMORTAL(result);
7475PyObject *RICH_COMPARE_GT_OBJECT_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
7477 if (Py_TYPE(operand1) == &PyFloat_Type) {
7478 return COMPARE_GT_OBJECT_FLOAT_FLOAT(operand1, operand2);
7481#if PYTHON_VERSION < 0x300
7482 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7486 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7491 PyTypeObject *type1 = Py_TYPE(operand1);
7493#if PYTHON_VERSION < 0x300
7495 if (type1 == &PyFloat_Type && !0) {
7497 richcmpfunc frich = PyFloat_Type.tp_richcompare;
7499 if (frich != NULL) {
7500 PyObject *result = (*frich)(operand1, operand2, Py_GT);
7502 if (result != Py_NotImplemented) {
7503 Py_LeaveRecursiveCall();
7508 Py_DECREF_IMMORTAL(result);
7512 cmpfunc fcmp = NULL;
7515 int c = (*fcmp)(operand1, operand2);
7516 c = adjust_tp_compare(c);
7518 Py_LeaveRecursiveCall();
7544 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7548 PyObject *result = BOOL_FROM(r);
7549 Py_INCREF_IMMORTAL(result);
7557 if (type1 != &PyFloat_Type && 0) {
7558 f = PyFloat_Type.tp_richcompare;
7561 PyObject *result = (*f)(operand2, operand1, Py_LT);
7563 if (result != Py_NotImplemented) {
7564 Py_LeaveRecursiveCall();
7569 Py_DECREF_IMMORTAL(result);
7573 f = TP_RICHCOMPARE(type1);
7575 PyObject *result = (*f)(operand1, operand2, Py_GT);
7577 if (result != Py_NotImplemented) {
7578 Py_LeaveRecursiveCall();
7583 Py_DECREF_IMMORTAL(result);
7586 f = PyFloat_Type.tp_richcompare;
7588 PyObject *result = (*f)(operand2, operand1, Py_LT);
7590 if (result != Py_NotImplemented) {
7591 Py_LeaveRecursiveCall();
7596 Py_DECREF_IMMORTAL(result);
7601 if (PyInstance_Check(operand1)) {
7602 cmpfunc fcmp = type1->tp_compare;
7603 c = (*fcmp)(operand1, operand2);
7605 cmpfunc fcmp = NULL;
7606 c = (*fcmp)(operand1, operand2);
7608 c = try_3way_compare(operand1, operand2);
7612 if (type1 == &PyFloat_Type) {
7613 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7614 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7616 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7617 }
else if (operand1 == Py_None) {
7620 }
else if (operand2 == Py_None) {
7623 }
else if (PyNumber_Check(operand1)) {
7626 if (PyNumber_Check(operand2)) {
7628 Py_uintptr_t aa = (Py_uintptr_t)type1;
7629 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
7631 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7635 }
else if (PyNumber_Check(operand2)) {
7639 int s = strcmp(type1->tp_name,
"float");
7647 Py_uintptr_t aa = (Py_uintptr_t)type1;
7648 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
7650 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7655 Py_LeaveRecursiveCall();
7657 if (unlikely(c <= -2)) {
7683 PyObject *result = BOOL_FROM(r);
7684 Py_INCREF_IMMORTAL(result);
7687 bool checked_reverse_op =
false;
7690 if (type1 != &PyFloat_Type && Nuitka_Type_IsSubtype(&PyFloat_Type, type1)) {
7691 f = PyFloat_Type.tp_richcompare;
7694 checked_reverse_op =
true;
7696 PyObject *result = (*f)(operand2, operand1, Py_LT);
7698 if (result != Py_NotImplemented) {
7699 Py_LeaveRecursiveCall();
7704 Py_DECREF_IMMORTAL(result);
7708 f = TP_RICHCOMPARE(type1);
7711 PyObject *result = (*f)(operand1, operand2, Py_GT);
7713 if (result != Py_NotImplemented) {
7714 Py_LeaveRecursiveCall();
7719 Py_DECREF_IMMORTAL(result);
7722 if (checked_reverse_op ==
false) {
7723 f = PyFloat_Type.tp_richcompare;
7726 PyObject *result = (*f)(operand2, operand1, Py_LT);
7728 if (result != Py_NotImplemented) {
7729 Py_LeaveRecursiveCall();
7734 Py_DECREF_IMMORTAL(result);
7738 Py_LeaveRecursiveCall();
7744 bool r = operand1 == operand2;
7745 PyObject *result = BOOL_FROM(r);
7746 Py_INCREF_IMMORTAL(result);
7750 bool r = operand1 != operand2;
7751 PyObject *result = BOOL_FROM(r);
7752 Py_INCREF_IMMORTAL(result);
7756#if PYTHON_VERSION < 0x360
7757 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > float()", type1->tp_name);
7759 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'float'", type1->tp_name);
7767PyObject *RICH_COMPARE_GT_OBJECT_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
7769 if (&PyFloat_Type == Py_TYPE(operand2)) {
7770 return COMPARE_GT_OBJECT_FLOAT_FLOAT(operand1, operand2);
7773#if PYTHON_VERSION < 0x300
7774 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7778 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7783 PyTypeObject *type2 = Py_TYPE(operand2);
7785#if PYTHON_VERSION < 0x300
7787 if (&PyFloat_Type == type2 && !0) {
7789 richcmpfunc frich = PyFloat_Type.tp_richcompare;
7791 if (frich != NULL) {
7792 PyObject *result = (*frich)(operand1, operand2, Py_GT);
7794 if (result != Py_NotImplemented) {
7795 Py_LeaveRecursiveCall();
7800 Py_DECREF_IMMORTAL(result);
7804 cmpfunc fcmp = NULL;
7807 int c = (*fcmp)(operand1, operand2);
7808 c = adjust_tp_compare(c);
7810 Py_LeaveRecursiveCall();
7836 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7840 PyObject *result = BOOL_FROM(r);
7841 Py_INCREF_IMMORTAL(result);
7849 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
7850 f = TP_RICHCOMPARE(type2);
7853 PyObject *result = (*f)(operand2, operand1, Py_LT);
7855 if (result != Py_NotImplemented) {
7856 Py_LeaveRecursiveCall();
7861 Py_DECREF_IMMORTAL(result);
7865 f = PyFloat_Type.tp_richcompare;
7867 PyObject *result = (*f)(operand1, operand2, Py_GT);
7869 if (result != Py_NotImplemented) {
7870 Py_LeaveRecursiveCall();
7875 Py_DECREF_IMMORTAL(result);
7878 f = TP_RICHCOMPARE(type2);
7880 PyObject *result = (*f)(operand2, operand1, Py_LT);
7882 if (result != Py_NotImplemented) {
7883 Py_LeaveRecursiveCall();
7888 Py_DECREF_IMMORTAL(result);
7894 cmpfunc fcmp = NULL;
7895 c = (*fcmp)(operand1, operand2);
7896 }
else if (PyInstance_Check(operand2)) {
7897 cmpfunc fcmp = type2->tp_compare;
7898 c = (*fcmp)(operand1, operand2);
7900 c = try_3way_compare(operand1, operand2);
7904 if (&PyFloat_Type == type2) {
7905 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7906 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7908 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7909 }
else if (operand1 == Py_None) {
7912 }
else if (operand2 == Py_None) {
7915 }
else if (PyNumber_Check(operand1)) {
7918 if (PyNumber_Check(operand2)) {
7920 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
7921 Py_uintptr_t bb = (Py_uintptr_t)type2;
7923 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7927 }
else if (PyNumber_Check(operand2)) {
7931 int s = strcmp(
"float", type2->tp_name);
7939 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
7940 Py_uintptr_t bb = (Py_uintptr_t)type2;
7942 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7947 Py_LeaveRecursiveCall();
7949 if (unlikely(c <= -2)) {
7975 PyObject *result = BOOL_FROM(r);
7976 Py_INCREF_IMMORTAL(result);
7979 bool checked_reverse_op =
false;
7982 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
7983 f = TP_RICHCOMPARE(type2);
7986 checked_reverse_op =
true;
7988 PyObject *result = (*f)(operand2, operand1, Py_LT);
7990 if (result != Py_NotImplemented) {
7991 Py_LeaveRecursiveCall();
7996 Py_DECREF_IMMORTAL(result);
8000 f = PyFloat_Type.tp_richcompare;
8003 PyObject *result = (*f)(operand1, operand2, Py_GT);
8005 if (result != Py_NotImplemented) {
8006 Py_LeaveRecursiveCall();
8011 Py_DECREF_IMMORTAL(result);
8014 if (checked_reverse_op ==
false) {
8015 f = TP_RICHCOMPARE(type2);
8018 PyObject *result = (*f)(operand2, operand1, Py_LT);
8020 if (result != Py_NotImplemented) {
8021 Py_LeaveRecursiveCall();
8026 Py_DECREF_IMMORTAL(result);
8030 Py_LeaveRecursiveCall();
8036 bool r = operand1 == operand2;
8037 PyObject *result = BOOL_FROM(r);
8038 Py_INCREF_IMMORTAL(result);
8042 bool r = operand1 != operand2;
8043 PyObject *result = BOOL_FROM(r);
8044 Py_INCREF_IMMORTAL(result);
8048#if PYTHON_VERSION < 0x360
8049 PyErr_Format(PyExc_TypeError,
"unorderable types: float() > %s()", type2->tp_name);
8051 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'float' and '%s'", type2->tp_name);
8058static bool COMPARE_GT_CBOOL_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8059 CHECK_OBJECT(operand1);
8060 assert(PyFloat_CheckExact(operand1));
8061 CHECK_OBJECT(operand2);
8062 assert(PyFloat_CheckExact(operand2));
8064 const double a = PyFloat_AS_DOUBLE(operand1);
8065 const double b = PyFloat_AS_DOUBLE(operand2);
8075nuitka_bool RICH_COMPARE_GT_NBOOL_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
8077 if (Py_TYPE(operand1) == &PyFloat_Type) {
8078 return COMPARE_GT_CBOOL_FLOAT_FLOAT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8081#if PYTHON_VERSION < 0x300
8082 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8083 return NUITKA_BOOL_EXCEPTION;
8086 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8087 return NUITKA_BOOL_EXCEPTION;
8091 PyTypeObject *type1 = Py_TYPE(operand1);
8093#if PYTHON_VERSION < 0x300
8095 if (type1 == &PyFloat_Type && !0) {
8097 richcmpfunc frich = PyFloat_Type.tp_richcompare;
8099 if (frich != NULL) {
8100 PyObject *result = (*frich)(operand1, operand2, Py_GT);
8102 if (result != Py_NotImplemented) {
8103 Py_LeaveRecursiveCall();
8105 if (unlikely(result == NULL)) {
8106 return NUITKA_BOOL_EXCEPTION;
8110 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8116 Py_DECREF_IMMORTAL(result);
8120 cmpfunc fcmp = NULL;
8123 int c = (*fcmp)(operand1, operand2);
8124 c = adjust_tp_compare(c);
8126 Py_LeaveRecursiveCall();
8129 return NUITKA_BOOL_EXCEPTION;
8152 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8156 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8165 if (type1 != &PyFloat_Type && 0) {
8166 f = PyFloat_Type.tp_richcompare;
8169 PyObject *result = (*f)(operand2, operand1, Py_LT);
8171 if (result != Py_NotImplemented) {
8172 Py_LeaveRecursiveCall();
8174 if (unlikely(result == NULL)) {
8175 return NUITKA_BOOL_EXCEPTION;
8179 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8185 Py_DECREF_IMMORTAL(result);
8189 f = TP_RICHCOMPARE(type1);
8191 PyObject *result = (*f)(operand1, operand2, Py_GT);
8193 if (result != Py_NotImplemented) {
8194 Py_LeaveRecursiveCall();
8196 if (unlikely(result == NULL)) {
8197 return NUITKA_BOOL_EXCEPTION;
8201 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8207 Py_DECREF_IMMORTAL(result);
8210 f = PyFloat_Type.tp_richcompare;
8212 PyObject *result = (*f)(operand2, operand1, Py_LT);
8214 if (result != Py_NotImplemented) {
8215 Py_LeaveRecursiveCall();
8217 if (unlikely(result == NULL)) {
8218 return NUITKA_BOOL_EXCEPTION;
8222 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8228 Py_DECREF_IMMORTAL(result);
8233 if (PyInstance_Check(operand1)) {
8234 cmpfunc fcmp = type1->tp_compare;
8235 c = (*fcmp)(operand1, operand2);
8237 cmpfunc fcmp = NULL;
8238 c = (*fcmp)(operand1, operand2);
8240 c = try_3way_compare(operand1, operand2);
8244 if (type1 == &PyFloat_Type) {
8245 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8246 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8248 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8249 }
else if (operand1 == Py_None) {
8252 }
else if (operand2 == Py_None) {
8255 }
else if (PyNumber_Check(operand1)) {
8258 if (PyNumber_Check(operand2)) {
8260 Py_uintptr_t aa = (Py_uintptr_t)type1;
8261 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
8263 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8267 }
else if (PyNumber_Check(operand2)) {
8271 int s = strcmp(type1->tp_name,
"float");
8279 Py_uintptr_t aa = (Py_uintptr_t)type1;
8280 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
8282 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8287 Py_LeaveRecursiveCall();
8289 if (unlikely(c <= -2)) {
8290 return NUITKA_BOOL_EXCEPTION;
8315 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8319 bool checked_reverse_op =
false;
8322 if (type1 != &PyFloat_Type && Nuitka_Type_IsSubtype(&PyFloat_Type, type1)) {
8323 f = PyFloat_Type.tp_richcompare;
8326 checked_reverse_op =
true;
8328 PyObject *result = (*f)(operand2, operand1, Py_LT);
8330 if (result != Py_NotImplemented) {
8331 Py_LeaveRecursiveCall();
8333 if (unlikely(result == NULL)) {
8334 return NUITKA_BOOL_EXCEPTION;
8338 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8344 Py_DECREF_IMMORTAL(result);
8348 f = TP_RICHCOMPARE(type1);
8351 PyObject *result = (*f)(operand1, operand2, Py_GT);
8353 if (result != Py_NotImplemented) {
8354 Py_LeaveRecursiveCall();
8356 if (unlikely(result == NULL)) {
8357 return NUITKA_BOOL_EXCEPTION;
8361 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8367 Py_DECREF_IMMORTAL(result);
8370 if (checked_reverse_op ==
false) {
8371 f = PyFloat_Type.tp_richcompare;
8374 PyObject *result = (*f)(operand2, operand1, Py_LT);
8376 if (result != Py_NotImplemented) {
8377 Py_LeaveRecursiveCall();
8379 if (unlikely(result == NULL)) {
8380 return NUITKA_BOOL_EXCEPTION;
8384 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8390 Py_DECREF_IMMORTAL(result);
8394 Py_LeaveRecursiveCall();
8400 bool r = operand1 == operand2;
8401 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8406 bool r = operand1 != operand2;
8407 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8412#if PYTHON_VERSION < 0x360
8413 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > float()", type1->tp_name);
8415 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'float'", type1->tp_name);
8417 return NUITKA_BOOL_EXCEPTION;
8423nuitka_bool RICH_COMPARE_GT_NBOOL_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
8425 if (&PyFloat_Type == Py_TYPE(operand2)) {
8426 return COMPARE_GT_CBOOL_FLOAT_FLOAT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8429#if PYTHON_VERSION < 0x300
8430 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8431 return NUITKA_BOOL_EXCEPTION;
8434 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8435 return NUITKA_BOOL_EXCEPTION;
8439 PyTypeObject *type2 = Py_TYPE(operand2);
8441#if PYTHON_VERSION < 0x300
8443 if (&PyFloat_Type == type2 && !0) {
8445 richcmpfunc frich = PyFloat_Type.tp_richcompare;
8447 if (frich != NULL) {
8448 PyObject *result = (*frich)(operand1, operand2, Py_GT);
8450 if (result != Py_NotImplemented) {
8451 Py_LeaveRecursiveCall();
8453 if (unlikely(result == NULL)) {
8454 return NUITKA_BOOL_EXCEPTION;
8458 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8464 Py_DECREF_IMMORTAL(result);
8468 cmpfunc fcmp = NULL;
8471 int c = (*fcmp)(operand1, operand2);
8472 c = adjust_tp_compare(c);
8474 Py_LeaveRecursiveCall();
8477 return NUITKA_BOOL_EXCEPTION;
8500 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8504 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8513 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8514 f = TP_RICHCOMPARE(type2);
8517 PyObject *result = (*f)(operand2, operand1, Py_LT);
8519 if (result != Py_NotImplemented) {
8520 Py_LeaveRecursiveCall();
8522 if (unlikely(result == NULL)) {
8523 return NUITKA_BOOL_EXCEPTION;
8527 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8533 Py_DECREF_IMMORTAL(result);
8537 f = PyFloat_Type.tp_richcompare;
8539 PyObject *result = (*f)(operand1, operand2, Py_GT);
8541 if (result != Py_NotImplemented) {
8542 Py_LeaveRecursiveCall();
8544 if (unlikely(result == NULL)) {
8545 return NUITKA_BOOL_EXCEPTION;
8549 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8555 Py_DECREF_IMMORTAL(result);
8558 f = TP_RICHCOMPARE(type2);
8560 PyObject *result = (*f)(operand2, operand1, Py_LT);
8562 if (result != Py_NotImplemented) {
8563 Py_LeaveRecursiveCall();
8565 if (unlikely(result == NULL)) {
8566 return NUITKA_BOOL_EXCEPTION;
8570 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8576 Py_DECREF_IMMORTAL(result);
8582 cmpfunc fcmp = NULL;
8583 c = (*fcmp)(operand1, operand2);
8584 }
else if (PyInstance_Check(operand2)) {
8585 cmpfunc fcmp = type2->tp_compare;
8586 c = (*fcmp)(operand1, operand2);
8588 c = try_3way_compare(operand1, operand2);
8592 if (&PyFloat_Type == type2) {
8593 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8594 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8596 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8597 }
else if (operand1 == Py_None) {
8600 }
else if (operand2 == Py_None) {
8603 }
else if (PyNumber_Check(operand1)) {
8606 if (PyNumber_Check(operand2)) {
8608 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8609 Py_uintptr_t bb = (Py_uintptr_t)type2;
8611 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8615 }
else if (PyNumber_Check(operand2)) {
8619 int s = strcmp(
"float", type2->tp_name);
8627 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8628 Py_uintptr_t bb = (Py_uintptr_t)type2;
8630 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8635 Py_LeaveRecursiveCall();
8637 if (unlikely(c <= -2)) {
8638 return NUITKA_BOOL_EXCEPTION;
8663 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8667 bool checked_reverse_op =
false;
8670 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8671 f = TP_RICHCOMPARE(type2);
8674 checked_reverse_op =
true;
8676 PyObject *result = (*f)(operand2, operand1, Py_LT);
8678 if (result != Py_NotImplemented) {
8679 Py_LeaveRecursiveCall();
8681 if (unlikely(result == NULL)) {
8682 return NUITKA_BOOL_EXCEPTION;
8686 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8692 Py_DECREF_IMMORTAL(result);
8696 f = PyFloat_Type.tp_richcompare;
8699 PyObject *result = (*f)(operand1, operand2, Py_GT);
8701 if (result != Py_NotImplemented) {
8702 Py_LeaveRecursiveCall();
8704 if (unlikely(result == NULL)) {
8705 return NUITKA_BOOL_EXCEPTION;
8709 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8715 Py_DECREF_IMMORTAL(result);
8718 if (checked_reverse_op ==
false) {
8719 f = TP_RICHCOMPARE(type2);
8722 PyObject *result = (*f)(operand2, operand1, Py_LT);
8724 if (result != Py_NotImplemented) {
8725 Py_LeaveRecursiveCall();
8727 if (unlikely(result == NULL)) {
8728 return NUITKA_BOOL_EXCEPTION;
8732 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8738 Py_DECREF_IMMORTAL(result);
8742 Py_LeaveRecursiveCall();
8748 bool r = operand1 == operand2;
8749 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8754 bool r = operand1 != operand2;
8755 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8760#if PYTHON_VERSION < 0x360
8761 PyErr_Format(PyExc_TypeError,
"unorderable types: float() > %s()", type2->tp_name);
8763 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'float' and '%s'", type2->tp_name);
8765 return NUITKA_BOOL_EXCEPTION;
8770static PyObject *COMPARE_GT_OBJECT_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
8771 CHECK_OBJECT(operand1);
8772 assert(PyTuple_CheckExact(operand1));
8773 CHECK_OBJECT(operand2);
8774 assert(PyTuple_CheckExact(operand2));
8776 PyTupleObject *a = (PyTupleObject *)operand1;
8777 PyTupleObject *b = (PyTupleObject *)operand2;
8779 Py_ssize_t len_a = Py_SIZE(a);
8780 Py_ssize_t len_b = Py_SIZE(b);
8783 nuitka_bool res = NUITKA_BOOL_TRUE;
8786 for (i = 0; i < len_a && i < len_b; i++) {
8787 PyObject *aa = a->ob_item[i];
8788 PyObject *bb = b->ob_item[i];
8794 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
8796 if (res == NUITKA_BOOL_EXCEPTION) {
8800 if (res == NUITKA_BOOL_FALSE) {
8806 if (found ==
false) {
8807 bool r = len_a > len_b;
8810 PyObject *result = BOOL_FROM(r);
8811 Py_INCREF_IMMORTAL(result);
8815 return RICH_COMPARE_GT_OBJECT_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
8818PyObject *RICH_COMPARE_GT_OBJECT_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
8820 if (Py_TYPE(operand1) == &PyTuple_Type) {
8821 return COMPARE_GT_OBJECT_TUPLE_TUPLE(operand1, operand2);
8824#if PYTHON_VERSION < 0x300
8825 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8829 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8834 PyTypeObject *type1 = Py_TYPE(operand1);
8836#if PYTHON_VERSION < 0x300
8838 if (type1 == &PyTuple_Type && !0) {
8840 richcmpfunc frich = PyTuple_Type.tp_richcompare;
8842 if (frich != NULL) {
8843 PyObject *result = (*frich)(operand1, operand2, Py_GT);
8845 if (result != Py_NotImplemented) {
8846 Py_LeaveRecursiveCall();
8851 Py_DECREF_IMMORTAL(result);
8855 cmpfunc fcmp = NULL;
8858 int c = (*fcmp)(operand1, operand2);
8859 c = adjust_tp_compare(c);
8861 Py_LeaveRecursiveCall();
8887 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8891 PyObject *result = BOOL_FROM(r);
8892 Py_INCREF_IMMORTAL(result);
8900 if (type1 != &PyTuple_Type && 0) {
8901 f = PyTuple_Type.tp_richcompare;
8904 PyObject *result = (*f)(operand2, operand1, Py_LT);
8906 if (result != Py_NotImplemented) {
8907 Py_LeaveRecursiveCall();
8912 Py_DECREF_IMMORTAL(result);
8916 f = TP_RICHCOMPARE(type1);
8918 PyObject *result = (*f)(operand1, operand2, Py_GT);
8920 if (result != Py_NotImplemented) {
8921 Py_LeaveRecursiveCall();
8926 Py_DECREF_IMMORTAL(result);
8929 f = PyTuple_Type.tp_richcompare;
8931 PyObject *result = (*f)(operand2, operand1, Py_LT);
8933 if (result != Py_NotImplemented) {
8934 Py_LeaveRecursiveCall();
8939 Py_DECREF_IMMORTAL(result);
8944 if (PyInstance_Check(operand1)) {
8945 cmpfunc fcmp = type1->tp_compare;
8946 c = (*fcmp)(operand1, operand2);
8948 cmpfunc fcmp = NULL;
8949 c = (*fcmp)(operand1, operand2);
8951 c = try_3way_compare(operand1, operand2);
8955 if (type1 == &PyTuple_Type) {
8956 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8957 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8959 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8960 }
else if (operand1 == Py_None) {
8963 }
else if (operand2 == Py_None) {
8966 }
else if (PyNumber_Check(operand1)) {
8969 if (PyNumber_Check(operand2)) {
8971 Py_uintptr_t aa = (Py_uintptr_t)type1;
8972 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
8974 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8978 }
else if (PyNumber_Check(operand2)) {
8982 int s = strcmp(type1->tp_name,
"tuple");
8990 Py_uintptr_t aa = (Py_uintptr_t)type1;
8991 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
8993 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8998 Py_LeaveRecursiveCall();
9000 if (unlikely(c <= -2)) {
9026 PyObject *result = BOOL_FROM(r);
9027 Py_INCREF_IMMORTAL(result);
9030 bool checked_reverse_op =
false;
9033 if (type1 != &PyTuple_Type && Nuitka_Type_IsSubtype(&PyTuple_Type, type1)) {
9034 f = PyTuple_Type.tp_richcompare;
9037 checked_reverse_op =
true;
9039 PyObject *result = (*f)(operand2, operand1, Py_LT);
9041 if (result != Py_NotImplemented) {
9042 Py_LeaveRecursiveCall();
9047 Py_DECREF_IMMORTAL(result);
9051 f = TP_RICHCOMPARE(type1);
9054 PyObject *result = (*f)(operand1, operand2, Py_GT);
9056 if (result != Py_NotImplemented) {
9057 Py_LeaveRecursiveCall();
9062 Py_DECREF_IMMORTAL(result);
9065 if (checked_reverse_op ==
false) {
9066 f = PyTuple_Type.tp_richcompare;
9069 PyObject *result = (*f)(operand2, operand1, Py_LT);
9071 if (result != Py_NotImplemented) {
9072 Py_LeaveRecursiveCall();
9077 Py_DECREF_IMMORTAL(result);
9081 Py_LeaveRecursiveCall();
9087 bool r = operand1 == operand2;
9088 PyObject *result = BOOL_FROM(r);
9089 Py_INCREF_IMMORTAL(result);
9093 bool r = operand1 != operand2;
9094 PyObject *result = BOOL_FROM(r);
9095 Py_INCREF_IMMORTAL(result);
9099#if PYTHON_VERSION < 0x360
9100 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > tuple()", type1->tp_name);
9102 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'tuple'", type1->tp_name);
9110PyObject *RICH_COMPARE_GT_OBJECT_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
9112 if (&PyTuple_Type == Py_TYPE(operand2)) {
9113 return COMPARE_GT_OBJECT_TUPLE_TUPLE(operand1, operand2);
9116#if PYTHON_VERSION < 0x300
9117 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9121 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9126 PyTypeObject *type2 = Py_TYPE(operand2);
9128#if PYTHON_VERSION < 0x300
9130 if (&PyTuple_Type == type2 && !0) {
9132 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9134 if (frich != NULL) {
9135 PyObject *result = (*frich)(operand1, operand2, Py_GT);
9137 if (result != Py_NotImplemented) {
9138 Py_LeaveRecursiveCall();
9143 Py_DECREF_IMMORTAL(result);
9147 cmpfunc fcmp = NULL;
9150 int c = (*fcmp)(operand1, operand2);
9151 c = adjust_tp_compare(c);
9153 Py_LeaveRecursiveCall();
9179 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9183 PyObject *result = BOOL_FROM(r);
9184 Py_INCREF_IMMORTAL(result);
9192 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9193 f = TP_RICHCOMPARE(type2);
9196 PyObject *result = (*f)(operand2, operand1, Py_LT);
9198 if (result != Py_NotImplemented) {
9199 Py_LeaveRecursiveCall();
9204 Py_DECREF_IMMORTAL(result);
9208 f = PyTuple_Type.tp_richcompare;
9210 PyObject *result = (*f)(operand1, operand2, Py_GT);
9212 if (result != Py_NotImplemented) {
9213 Py_LeaveRecursiveCall();
9218 Py_DECREF_IMMORTAL(result);
9221 f = TP_RICHCOMPARE(type2);
9223 PyObject *result = (*f)(operand2, operand1, Py_LT);
9225 if (result != Py_NotImplemented) {
9226 Py_LeaveRecursiveCall();
9231 Py_DECREF_IMMORTAL(result);
9237 cmpfunc fcmp = NULL;
9238 c = (*fcmp)(operand1, operand2);
9239 }
else if (PyInstance_Check(operand2)) {
9240 cmpfunc fcmp = type2->tp_compare;
9241 c = (*fcmp)(operand1, operand2);
9243 c = try_3way_compare(operand1, operand2);
9247 if (&PyTuple_Type == type2) {
9248 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9249 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9251 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9252 }
else if (operand1 == Py_None) {
9255 }
else if (operand2 == Py_None) {
9258 }
else if (PyNumber_Check(operand1)) {
9261 if (PyNumber_Check(operand2)) {
9263 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
9264 Py_uintptr_t bb = (Py_uintptr_t)type2;
9266 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9270 }
else if (PyNumber_Check(operand2)) {
9274 int s = strcmp(
"tuple", type2->tp_name);
9282 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
9283 Py_uintptr_t bb = (Py_uintptr_t)type2;
9285 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9290 Py_LeaveRecursiveCall();
9292 if (unlikely(c <= -2)) {
9318 PyObject *result = BOOL_FROM(r);
9319 Py_INCREF_IMMORTAL(result);
9322 bool checked_reverse_op =
false;
9325 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9326 f = TP_RICHCOMPARE(type2);
9329 checked_reverse_op =
true;
9331 PyObject *result = (*f)(operand2, operand1, Py_LT);
9333 if (result != Py_NotImplemented) {
9334 Py_LeaveRecursiveCall();
9339 Py_DECREF_IMMORTAL(result);
9343 f = PyTuple_Type.tp_richcompare;
9346 PyObject *result = (*f)(operand1, operand2, Py_GT);
9348 if (result != Py_NotImplemented) {
9349 Py_LeaveRecursiveCall();
9354 Py_DECREF_IMMORTAL(result);
9357 if (checked_reverse_op ==
false) {
9358 f = TP_RICHCOMPARE(type2);
9361 PyObject *result = (*f)(operand2, operand1, Py_LT);
9363 if (result != Py_NotImplemented) {
9364 Py_LeaveRecursiveCall();
9369 Py_DECREF_IMMORTAL(result);
9373 Py_LeaveRecursiveCall();
9379 bool r = operand1 == operand2;
9380 PyObject *result = BOOL_FROM(r);
9381 Py_INCREF_IMMORTAL(result);
9385 bool r = operand1 != operand2;
9386 PyObject *result = BOOL_FROM(r);
9387 Py_INCREF_IMMORTAL(result);
9391#if PYTHON_VERSION < 0x360
9392 PyErr_Format(PyExc_TypeError,
"unorderable types: tuple() > %s()", type2->tp_name);
9394 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'tuple' and '%s'", type2->tp_name);
9402PyObject *RICH_COMPARE_GT_OBJECT_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
9404 return COMPARE_GT_OBJECT_TUPLE_TUPLE(operand1, operand2);
9407static nuitka_bool COMPARE_GT_NBOOL_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
9408 CHECK_OBJECT(operand1);
9409 assert(PyTuple_CheckExact(operand1));
9410 CHECK_OBJECT(operand2);
9411 assert(PyTuple_CheckExact(operand2));
9413 PyTupleObject *a = (PyTupleObject *)operand1;
9414 PyTupleObject *b = (PyTupleObject *)operand2;
9416 Py_ssize_t len_a = Py_SIZE(a);
9417 Py_ssize_t len_b = Py_SIZE(b);
9420 nuitka_bool res = NUITKA_BOOL_TRUE;
9423 for (i = 0; i < len_a && i < len_b; i++) {
9424 PyObject *aa = a->ob_item[i];
9425 PyObject *bb = b->ob_item[i];
9431 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
9433 if (res == NUITKA_BOOL_EXCEPTION) {
9434 return NUITKA_BOOL_EXCEPTION;
9437 if (res == NUITKA_BOOL_FALSE) {
9443 if (found ==
false) {
9444 bool r = len_a > len_b;
9447 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9452 return RICH_COMPARE_GT_NBOOL_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
9455nuitka_bool RICH_COMPARE_GT_NBOOL_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
9457 if (Py_TYPE(operand1) == &PyTuple_Type) {
9458 return COMPARE_GT_NBOOL_TUPLE_TUPLE(operand1, operand2);
9461#if PYTHON_VERSION < 0x300
9462 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9463 return NUITKA_BOOL_EXCEPTION;
9466 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9467 return NUITKA_BOOL_EXCEPTION;
9471 PyTypeObject *type1 = Py_TYPE(operand1);
9473#if PYTHON_VERSION < 0x300
9475 if (type1 == &PyTuple_Type && !0) {
9477 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9479 if (frich != NULL) {
9480 PyObject *result = (*frich)(operand1, operand2, Py_GT);
9482 if (result != Py_NotImplemented) {
9483 Py_LeaveRecursiveCall();
9485 if (unlikely(result == NULL)) {
9486 return NUITKA_BOOL_EXCEPTION;
9490 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9496 Py_DECREF_IMMORTAL(result);
9500 cmpfunc fcmp = NULL;
9503 int c = (*fcmp)(operand1, operand2);
9504 c = adjust_tp_compare(c);
9506 Py_LeaveRecursiveCall();
9509 return NUITKA_BOOL_EXCEPTION;
9532 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9536 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9545 if (type1 != &PyTuple_Type && 0) {
9546 f = PyTuple_Type.tp_richcompare;
9549 PyObject *result = (*f)(operand2, operand1, Py_LT);
9551 if (result != Py_NotImplemented) {
9552 Py_LeaveRecursiveCall();
9554 if (unlikely(result == NULL)) {
9555 return NUITKA_BOOL_EXCEPTION;
9559 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9565 Py_DECREF_IMMORTAL(result);
9569 f = TP_RICHCOMPARE(type1);
9571 PyObject *result = (*f)(operand1, operand2, Py_GT);
9573 if (result != Py_NotImplemented) {
9574 Py_LeaveRecursiveCall();
9576 if (unlikely(result == NULL)) {
9577 return NUITKA_BOOL_EXCEPTION;
9581 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9587 Py_DECREF_IMMORTAL(result);
9590 f = PyTuple_Type.tp_richcompare;
9592 PyObject *result = (*f)(operand2, operand1, Py_LT);
9594 if (result != Py_NotImplemented) {
9595 Py_LeaveRecursiveCall();
9597 if (unlikely(result == NULL)) {
9598 return NUITKA_BOOL_EXCEPTION;
9602 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9608 Py_DECREF_IMMORTAL(result);
9613 if (PyInstance_Check(operand1)) {
9614 cmpfunc fcmp = type1->tp_compare;
9615 c = (*fcmp)(operand1, operand2);
9617 cmpfunc fcmp = NULL;
9618 c = (*fcmp)(operand1, operand2);
9620 c = try_3way_compare(operand1, operand2);
9624 if (type1 == &PyTuple_Type) {
9625 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9626 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9628 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9629 }
else if (operand1 == Py_None) {
9632 }
else if (operand2 == Py_None) {
9635 }
else if (PyNumber_Check(operand1)) {
9638 if (PyNumber_Check(operand2)) {
9640 Py_uintptr_t aa = (Py_uintptr_t)type1;
9641 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9643 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9647 }
else if (PyNumber_Check(operand2)) {
9651 int s = strcmp(type1->tp_name,
"tuple");
9659 Py_uintptr_t aa = (Py_uintptr_t)type1;
9660 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9662 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9667 Py_LeaveRecursiveCall();
9669 if (unlikely(c <= -2)) {
9670 return NUITKA_BOOL_EXCEPTION;
9695 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9699 bool checked_reverse_op =
false;
9702 if (type1 != &PyTuple_Type && Nuitka_Type_IsSubtype(&PyTuple_Type, type1)) {
9703 f = PyTuple_Type.tp_richcompare;
9706 checked_reverse_op =
true;
9708 PyObject *result = (*f)(operand2, operand1, Py_LT);
9710 if (result != Py_NotImplemented) {
9711 Py_LeaveRecursiveCall();
9713 if (unlikely(result == NULL)) {
9714 return NUITKA_BOOL_EXCEPTION;
9718 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9724 Py_DECREF_IMMORTAL(result);
9728 f = TP_RICHCOMPARE(type1);
9731 PyObject *result = (*f)(operand1, operand2, Py_GT);
9733 if (result != Py_NotImplemented) {
9734 Py_LeaveRecursiveCall();
9736 if (unlikely(result == NULL)) {
9737 return NUITKA_BOOL_EXCEPTION;
9741 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9747 Py_DECREF_IMMORTAL(result);
9750 if (checked_reverse_op ==
false) {
9751 f = PyTuple_Type.tp_richcompare;
9754 PyObject *result = (*f)(operand2, operand1, Py_LT);
9756 if (result != Py_NotImplemented) {
9757 Py_LeaveRecursiveCall();
9759 if (unlikely(result == NULL)) {
9760 return NUITKA_BOOL_EXCEPTION;
9764 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9770 Py_DECREF_IMMORTAL(result);
9774 Py_LeaveRecursiveCall();
9780 bool r = operand1 == operand2;
9781 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9786 bool r = operand1 != operand2;
9787 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9792#if PYTHON_VERSION < 0x360
9793 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > tuple()", type1->tp_name);
9795 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'tuple'", type1->tp_name);
9797 return NUITKA_BOOL_EXCEPTION;
9803nuitka_bool RICH_COMPARE_GT_NBOOL_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
9805 if (&PyTuple_Type == Py_TYPE(operand2)) {
9806 return COMPARE_GT_NBOOL_TUPLE_TUPLE(operand1, operand2);
9809#if PYTHON_VERSION < 0x300
9810 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9811 return NUITKA_BOOL_EXCEPTION;
9814 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9815 return NUITKA_BOOL_EXCEPTION;
9819 PyTypeObject *type2 = Py_TYPE(operand2);
9821#if PYTHON_VERSION < 0x300
9823 if (&PyTuple_Type == type2 && !0) {
9825 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9827 if (frich != NULL) {
9828 PyObject *result = (*frich)(operand1, operand2, Py_GT);
9830 if (result != Py_NotImplemented) {
9831 Py_LeaveRecursiveCall();
9833 if (unlikely(result == NULL)) {
9834 return NUITKA_BOOL_EXCEPTION;
9838 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9844 Py_DECREF_IMMORTAL(result);
9848 cmpfunc fcmp = NULL;
9851 int c = (*fcmp)(operand1, operand2);
9852 c = adjust_tp_compare(c);
9854 Py_LeaveRecursiveCall();
9857 return NUITKA_BOOL_EXCEPTION;
9880 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9884 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9893 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9894 f = TP_RICHCOMPARE(type2);
9897 PyObject *result = (*f)(operand2, operand1, Py_LT);
9899 if (result != Py_NotImplemented) {
9900 Py_LeaveRecursiveCall();
9902 if (unlikely(result == NULL)) {
9903 return NUITKA_BOOL_EXCEPTION;
9907 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9913 Py_DECREF_IMMORTAL(result);
9917 f = PyTuple_Type.tp_richcompare;
9919 PyObject *result = (*f)(operand1, operand2, Py_GT);
9921 if (result != Py_NotImplemented) {
9922 Py_LeaveRecursiveCall();
9924 if (unlikely(result == NULL)) {
9925 return NUITKA_BOOL_EXCEPTION;
9929 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9935 Py_DECREF_IMMORTAL(result);
9938 f = TP_RICHCOMPARE(type2);
9940 PyObject *result = (*f)(operand2, operand1, Py_LT);
9942 if (result != Py_NotImplemented) {
9943 Py_LeaveRecursiveCall();
9945 if (unlikely(result == NULL)) {
9946 return NUITKA_BOOL_EXCEPTION;
9950 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9956 Py_DECREF_IMMORTAL(result);
9962 cmpfunc fcmp = NULL;
9963 c = (*fcmp)(operand1, operand2);
9964 }
else if (PyInstance_Check(operand2)) {
9965 cmpfunc fcmp = type2->tp_compare;
9966 c = (*fcmp)(operand1, operand2);
9968 c = try_3way_compare(operand1, operand2);
9972 if (&PyTuple_Type == type2) {
9973 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9974 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9976 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9977 }
else if (operand1 == Py_None) {
9980 }
else if (operand2 == Py_None) {
9983 }
else if (PyNumber_Check(operand1)) {
9986 if (PyNumber_Check(operand2)) {
9988 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
9989 Py_uintptr_t bb = (Py_uintptr_t)type2;
9991 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9995 }
else if (PyNumber_Check(operand2)) {
9999 int s = strcmp(
"tuple", type2->tp_name);
10003 }
else if (s > 0) {
10007 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
10008 Py_uintptr_t bb = (Py_uintptr_t)type2;
10010 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10015 Py_LeaveRecursiveCall();
10017 if (unlikely(c <= -2)) {
10018 return NUITKA_BOOL_EXCEPTION;
10043 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10047 bool checked_reverse_op =
false;
10050 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
10051 f = TP_RICHCOMPARE(type2);
10054 checked_reverse_op =
true;
10056 PyObject *result = (*f)(operand2, operand1, Py_LT);
10058 if (result != Py_NotImplemented) {
10059 Py_LeaveRecursiveCall();
10061 if (unlikely(result == NULL)) {
10062 return NUITKA_BOOL_EXCEPTION;
10066 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10072 Py_DECREF_IMMORTAL(result);
10076 f = PyTuple_Type.tp_richcompare;
10079 PyObject *result = (*f)(operand1, operand2, Py_GT);
10081 if (result != Py_NotImplemented) {
10082 Py_LeaveRecursiveCall();
10084 if (unlikely(result == NULL)) {
10085 return NUITKA_BOOL_EXCEPTION;
10089 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10095 Py_DECREF_IMMORTAL(result);
10098 if (checked_reverse_op ==
false) {
10099 f = TP_RICHCOMPARE(type2);
10102 PyObject *result = (*f)(operand2, operand1, Py_LT);
10104 if (result != Py_NotImplemented) {
10105 Py_LeaveRecursiveCall();
10107 if (unlikely(result == NULL)) {
10108 return NUITKA_BOOL_EXCEPTION;
10112 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10118 Py_DECREF_IMMORTAL(result);
10122 Py_LeaveRecursiveCall();
10128 bool r = operand1 == operand2;
10129 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10134 bool r = operand1 != operand2;
10135 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10140#if PYTHON_VERSION < 0x360
10141 PyErr_Format(PyExc_TypeError,
"unorderable types: tuple() > %s()", type2->tp_name);
10143 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'tuple' and '%s'", type2->tp_name);
10145 return NUITKA_BOOL_EXCEPTION;
10151nuitka_bool RICH_COMPARE_GT_NBOOL_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
10153 return COMPARE_GT_NBOOL_TUPLE_TUPLE(operand1, operand2);
10156static PyObject *COMPARE_GT_OBJECT_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10157 CHECK_OBJECT(operand1);
10158 assert(PyList_CheckExact(operand1));
10159 CHECK_OBJECT(operand2);
10160 assert(PyList_CheckExact(operand2));
10162 PyListObject *a = (PyListObject *)operand1;
10163 PyListObject *b = (PyListObject *)operand2;
10165 bool found =
false;
10166 nuitka_bool res = NUITKA_BOOL_TRUE;
10169 for (i = 0; i < Py_SIZE(a) && i < Py_SIZE(b); i++) {
10170 PyObject *aa = a->ob_item[i];
10171 PyObject *bb = b->ob_item[i];
10179 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
10183 if (res == NUITKA_BOOL_EXCEPTION) {
10187 if (res == NUITKA_BOOL_FALSE) {
10193 if (found ==
false) {
10194 bool r = Py_SIZE(a) > Py_SIZE(b);
10197 PyObject *result = BOOL_FROM(r);
10198 Py_INCREF_IMMORTAL(result);
10202 return RICH_COMPARE_GT_OBJECT_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
10205PyObject *RICH_COMPARE_GT_OBJECT_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
10207 if (Py_TYPE(operand1) == &PyList_Type) {
10208 return COMPARE_GT_OBJECT_LIST_LIST(operand1, operand2);
10211#if PYTHON_VERSION < 0x300
10212 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10216 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10221 PyTypeObject *type1 = Py_TYPE(operand1);
10223#if PYTHON_VERSION < 0x300
10225 if (type1 == &PyList_Type && !0) {
10227 richcmpfunc frich = PyList_Type.tp_richcompare;
10229 if (frich != NULL) {
10230 PyObject *result = (*frich)(operand1, operand2, Py_GT);
10232 if (result != Py_NotImplemented) {
10233 Py_LeaveRecursiveCall();
10238 Py_DECREF_IMMORTAL(result);
10242 cmpfunc fcmp = NULL;
10244 if (fcmp != NULL) {
10245 int c = (*fcmp)(operand1, operand2);
10246 c = adjust_tp_compare(c);
10248 Py_LeaveRecursiveCall();
10274 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10278 PyObject *result = BOOL_FROM(r);
10279 Py_INCREF_IMMORTAL(result);
10287 if (type1 != &PyList_Type && 0) {
10288 f = PyList_Type.tp_richcompare;
10291 PyObject *result = (*f)(operand2, operand1, Py_LT);
10293 if (result != Py_NotImplemented) {
10294 Py_LeaveRecursiveCall();
10299 Py_DECREF_IMMORTAL(result);
10303 f = TP_RICHCOMPARE(type1);
10305 PyObject *result = (*f)(operand1, operand2, Py_GT);
10307 if (result != Py_NotImplemented) {
10308 Py_LeaveRecursiveCall();
10313 Py_DECREF_IMMORTAL(result);
10316 f = PyList_Type.tp_richcompare;
10318 PyObject *result = (*f)(operand2, operand1, Py_LT);
10320 if (result != Py_NotImplemented) {
10321 Py_LeaveRecursiveCall();
10326 Py_DECREF_IMMORTAL(result);
10331 if (PyInstance_Check(operand1)) {
10332 cmpfunc fcmp = type1->tp_compare;
10333 c = (*fcmp)(operand1, operand2);
10335 cmpfunc fcmp = NULL;
10336 c = (*fcmp)(operand1, operand2);
10338 c = try_3way_compare(operand1, operand2);
10342 if (type1 == &PyList_Type) {
10343 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10344 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10346 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10347 }
else if (operand1 == Py_None) {
10350 }
else if (operand2 == Py_None) {
10353 }
else if (PyNumber_Check(operand1)) {
10356 if (PyNumber_Check(operand2)) {
10358 Py_uintptr_t aa = (Py_uintptr_t)type1;
10359 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
10361 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10365 }
else if (PyNumber_Check(operand2)) {
10369 int s = strcmp(type1->tp_name,
"list");
10373 }
else if (s > 0) {
10377 Py_uintptr_t aa = (Py_uintptr_t)type1;
10378 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
10380 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10385 Py_LeaveRecursiveCall();
10387 if (unlikely(c <= -2)) {
10413 PyObject *result = BOOL_FROM(r);
10414 Py_INCREF_IMMORTAL(result);
10417 bool checked_reverse_op =
false;
10420 if (type1 != &PyList_Type && Nuitka_Type_IsSubtype(&PyList_Type, type1)) {
10421 f = PyList_Type.tp_richcompare;
10424 checked_reverse_op =
true;
10426 PyObject *result = (*f)(operand2, operand1, Py_LT);
10428 if (result != Py_NotImplemented) {
10429 Py_LeaveRecursiveCall();
10434 Py_DECREF_IMMORTAL(result);
10438 f = TP_RICHCOMPARE(type1);
10441 PyObject *result = (*f)(operand1, operand2, Py_GT);
10443 if (result != Py_NotImplemented) {
10444 Py_LeaveRecursiveCall();
10449 Py_DECREF_IMMORTAL(result);
10452 if (checked_reverse_op ==
false) {
10453 f = PyList_Type.tp_richcompare;
10456 PyObject *result = (*f)(operand2, operand1, Py_LT);
10458 if (result != Py_NotImplemented) {
10459 Py_LeaveRecursiveCall();
10464 Py_DECREF_IMMORTAL(result);
10468 Py_LeaveRecursiveCall();
10474 bool r = operand1 == operand2;
10475 PyObject *result = BOOL_FROM(r);
10476 Py_INCREF_IMMORTAL(result);
10480 bool r = operand1 != operand2;
10481 PyObject *result = BOOL_FROM(r);
10482 Py_INCREF_IMMORTAL(result);
10486#if PYTHON_VERSION < 0x360
10487 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > list()", type1->tp_name);
10489 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'list'", type1->tp_name);
10497PyObject *RICH_COMPARE_GT_OBJECT_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
10499 if (&PyList_Type == Py_TYPE(operand2)) {
10500 return COMPARE_GT_OBJECT_LIST_LIST(operand1, operand2);
10503#if PYTHON_VERSION < 0x300
10504 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10508 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10513 PyTypeObject *type2 = Py_TYPE(operand2);
10515#if PYTHON_VERSION < 0x300
10517 if (&PyList_Type == type2 && !0) {
10519 richcmpfunc frich = PyList_Type.tp_richcompare;
10521 if (frich != NULL) {
10522 PyObject *result = (*frich)(operand1, operand2, Py_GT);
10524 if (result != Py_NotImplemented) {
10525 Py_LeaveRecursiveCall();
10530 Py_DECREF_IMMORTAL(result);
10534 cmpfunc fcmp = NULL;
10536 if (fcmp != NULL) {
10537 int c = (*fcmp)(operand1, operand2);
10538 c = adjust_tp_compare(c);
10540 Py_LeaveRecursiveCall();
10566 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10570 PyObject *result = BOOL_FROM(r);
10571 Py_INCREF_IMMORTAL(result);
10579 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
10580 f = TP_RICHCOMPARE(type2);
10583 PyObject *result = (*f)(operand2, operand1, Py_LT);
10585 if (result != Py_NotImplemented) {
10586 Py_LeaveRecursiveCall();
10591 Py_DECREF_IMMORTAL(result);
10595 f = PyList_Type.tp_richcompare;
10597 PyObject *result = (*f)(operand1, operand2, Py_GT);
10599 if (result != Py_NotImplemented) {
10600 Py_LeaveRecursiveCall();
10605 Py_DECREF_IMMORTAL(result);
10608 f = TP_RICHCOMPARE(type2);
10610 PyObject *result = (*f)(operand2, operand1, Py_LT);
10612 if (result != Py_NotImplemented) {
10613 Py_LeaveRecursiveCall();
10618 Py_DECREF_IMMORTAL(result);
10624 cmpfunc fcmp = NULL;
10625 c = (*fcmp)(operand1, operand2);
10626 }
else if (PyInstance_Check(operand2)) {
10627 cmpfunc fcmp = type2->tp_compare;
10628 c = (*fcmp)(operand1, operand2);
10630 c = try_3way_compare(operand1, operand2);
10634 if (&PyList_Type == type2) {
10635 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10636 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10638 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10639 }
else if (operand1 == Py_None) {
10642 }
else if (operand2 == Py_None) {
10645 }
else if (PyNumber_Check(operand1)) {
10648 if (PyNumber_Check(operand2)) {
10650 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
10651 Py_uintptr_t bb = (Py_uintptr_t)type2;
10653 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10657 }
else if (PyNumber_Check(operand2)) {
10661 int s = strcmp(
"list", type2->tp_name);
10665 }
else if (s > 0) {
10669 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
10670 Py_uintptr_t bb = (Py_uintptr_t)type2;
10672 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10677 Py_LeaveRecursiveCall();
10679 if (unlikely(c <= -2)) {
10705 PyObject *result = BOOL_FROM(r);
10706 Py_INCREF_IMMORTAL(result);
10709 bool checked_reverse_op =
false;
10712 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
10713 f = TP_RICHCOMPARE(type2);
10716 checked_reverse_op =
true;
10718 PyObject *result = (*f)(operand2, operand1, Py_LT);
10720 if (result != Py_NotImplemented) {
10721 Py_LeaveRecursiveCall();
10726 Py_DECREF_IMMORTAL(result);
10730 f = PyList_Type.tp_richcompare;
10733 PyObject *result = (*f)(operand1, operand2, Py_GT);
10735 if (result != Py_NotImplemented) {
10736 Py_LeaveRecursiveCall();
10741 Py_DECREF_IMMORTAL(result);
10744 if (checked_reverse_op ==
false) {
10745 f = TP_RICHCOMPARE(type2);
10748 PyObject *result = (*f)(operand2, operand1, Py_LT);
10750 if (result != Py_NotImplemented) {
10751 Py_LeaveRecursiveCall();
10756 Py_DECREF_IMMORTAL(result);
10760 Py_LeaveRecursiveCall();
10766 bool r = operand1 == operand2;
10767 PyObject *result = BOOL_FROM(r);
10768 Py_INCREF_IMMORTAL(result);
10772 bool r = operand1 != operand2;
10773 PyObject *result = BOOL_FROM(r);
10774 Py_INCREF_IMMORTAL(result);
10778#if PYTHON_VERSION < 0x360
10779 PyErr_Format(PyExc_TypeError,
"unorderable types: list() > %s()", type2->tp_name);
10781 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'list' and '%s'", type2->tp_name);
10789PyObject *RICH_COMPARE_GT_OBJECT_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10791 return COMPARE_GT_OBJECT_LIST_LIST(operand1, operand2);
10794static nuitka_bool COMPARE_GT_NBOOL_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10795 CHECK_OBJECT(operand1);
10796 assert(PyList_CheckExact(operand1));
10797 CHECK_OBJECT(operand2);
10798 assert(PyList_CheckExact(operand2));
10800 PyListObject *a = (PyListObject *)operand1;
10801 PyListObject *b = (PyListObject *)operand2;
10803 bool found =
false;
10804 nuitka_bool res = NUITKA_BOOL_TRUE;
10807 for (i = 0; i < Py_SIZE(a) && i < Py_SIZE(b); i++) {
10808 PyObject *aa = a->ob_item[i];
10809 PyObject *bb = b->ob_item[i];
10817 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
10821 if (res == NUITKA_BOOL_EXCEPTION) {
10822 return NUITKA_BOOL_EXCEPTION;
10825 if (res == NUITKA_BOOL_FALSE) {
10831 if (found ==
false) {
10832 bool r = Py_SIZE(a) > Py_SIZE(b);
10835 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10840 return RICH_COMPARE_GT_NBOOL_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
10843nuitka_bool RICH_COMPARE_GT_NBOOL_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
10845 if (Py_TYPE(operand1) == &PyList_Type) {
10846 return COMPARE_GT_NBOOL_LIST_LIST(operand1, operand2);
10849#if PYTHON_VERSION < 0x300
10850 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10851 return NUITKA_BOOL_EXCEPTION;
10854 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10855 return NUITKA_BOOL_EXCEPTION;
10859 PyTypeObject *type1 = Py_TYPE(operand1);
10861#if PYTHON_VERSION < 0x300
10863 if (type1 == &PyList_Type && !0) {
10865 richcmpfunc frich = PyList_Type.tp_richcompare;
10867 if (frich != NULL) {
10868 PyObject *result = (*frich)(operand1, operand2, Py_GT);
10870 if (result != Py_NotImplemented) {
10871 Py_LeaveRecursiveCall();
10873 if (unlikely(result == NULL)) {
10874 return NUITKA_BOOL_EXCEPTION;
10878 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10884 Py_DECREF_IMMORTAL(result);
10888 cmpfunc fcmp = NULL;
10890 if (fcmp != NULL) {
10891 int c = (*fcmp)(operand1, operand2);
10892 c = adjust_tp_compare(c);
10894 Py_LeaveRecursiveCall();
10897 return NUITKA_BOOL_EXCEPTION;
10920 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10924 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10933 if (type1 != &PyList_Type && 0) {
10934 f = PyList_Type.tp_richcompare;
10937 PyObject *result = (*f)(operand2, operand1, Py_LT);
10939 if (result != Py_NotImplemented) {
10940 Py_LeaveRecursiveCall();
10942 if (unlikely(result == NULL)) {
10943 return NUITKA_BOOL_EXCEPTION;
10947 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10953 Py_DECREF_IMMORTAL(result);
10957 f = TP_RICHCOMPARE(type1);
10959 PyObject *result = (*f)(operand1, operand2, Py_GT);
10961 if (result != Py_NotImplemented) {
10962 Py_LeaveRecursiveCall();
10964 if (unlikely(result == NULL)) {
10965 return NUITKA_BOOL_EXCEPTION;
10969 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10975 Py_DECREF_IMMORTAL(result);
10978 f = PyList_Type.tp_richcompare;
10980 PyObject *result = (*f)(operand2, operand1, Py_LT);
10982 if (result != Py_NotImplemented) {
10983 Py_LeaveRecursiveCall();
10985 if (unlikely(result == NULL)) {
10986 return NUITKA_BOOL_EXCEPTION;
10990 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10996 Py_DECREF_IMMORTAL(result);
11001 if (PyInstance_Check(operand1)) {
11002 cmpfunc fcmp = type1->tp_compare;
11003 c = (*fcmp)(operand1, operand2);
11005 cmpfunc fcmp = NULL;
11006 c = (*fcmp)(operand1, operand2);
11008 c = try_3way_compare(operand1, operand2);
11012 if (type1 == &PyList_Type) {
11013 Py_uintptr_t aa = (Py_uintptr_t)operand1;
11014 Py_uintptr_t bb = (Py_uintptr_t)operand2;
11016 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11017 }
else if (operand1 == Py_None) {
11020 }
else if (operand2 == Py_None) {
11023 }
else if (PyNumber_Check(operand1)) {
11026 if (PyNumber_Check(operand2)) {
11028 Py_uintptr_t aa = (Py_uintptr_t)type1;
11029 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
11031 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11035 }
else if (PyNumber_Check(operand2)) {
11039 int s = strcmp(type1->tp_name,
"list");
11043 }
else if (s > 0) {
11047 Py_uintptr_t aa = (Py_uintptr_t)type1;
11048 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
11050 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11055 Py_LeaveRecursiveCall();
11057 if (unlikely(c <= -2)) {
11058 return NUITKA_BOOL_EXCEPTION;
11083 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11087 bool checked_reverse_op =
false;
11090 if (type1 != &PyList_Type && Nuitka_Type_IsSubtype(&PyList_Type, type1)) {
11091 f = PyList_Type.tp_richcompare;
11094 checked_reverse_op =
true;
11096 PyObject *result = (*f)(operand2, operand1, Py_LT);
11098 if (result != Py_NotImplemented) {
11099 Py_LeaveRecursiveCall();
11101 if (unlikely(result == NULL)) {
11102 return NUITKA_BOOL_EXCEPTION;
11106 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11112 Py_DECREF_IMMORTAL(result);
11116 f = TP_RICHCOMPARE(type1);
11119 PyObject *result = (*f)(operand1, operand2, Py_GT);
11121 if (result != Py_NotImplemented) {
11122 Py_LeaveRecursiveCall();
11124 if (unlikely(result == NULL)) {
11125 return NUITKA_BOOL_EXCEPTION;
11129 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11135 Py_DECREF_IMMORTAL(result);
11138 if (checked_reverse_op ==
false) {
11139 f = PyList_Type.tp_richcompare;
11142 PyObject *result = (*f)(operand2, operand1, Py_LT);
11144 if (result != Py_NotImplemented) {
11145 Py_LeaveRecursiveCall();
11147 if (unlikely(result == NULL)) {
11148 return NUITKA_BOOL_EXCEPTION;
11152 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11158 Py_DECREF_IMMORTAL(result);
11162 Py_LeaveRecursiveCall();
11168 bool r = operand1 == operand2;
11169 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11174 bool r = operand1 != operand2;
11175 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11180#if PYTHON_VERSION < 0x360
11181 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() > list()", type1->tp_name);
11183 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of '%s' and 'list'", type1->tp_name);
11185 return NUITKA_BOOL_EXCEPTION;
11191nuitka_bool RICH_COMPARE_GT_NBOOL_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
11193 if (&PyList_Type == Py_TYPE(operand2)) {
11194 return COMPARE_GT_NBOOL_LIST_LIST(operand1, operand2);
11197#if PYTHON_VERSION < 0x300
11198 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
11199 return NUITKA_BOOL_EXCEPTION;
11202 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
11203 return NUITKA_BOOL_EXCEPTION;
11207 PyTypeObject *type2 = Py_TYPE(operand2);
11209#if PYTHON_VERSION < 0x300
11211 if (&PyList_Type == type2 && !0) {
11213 richcmpfunc frich = PyList_Type.tp_richcompare;
11215 if (frich != NULL) {
11216 PyObject *result = (*frich)(operand1, operand2, Py_GT);
11218 if (result != Py_NotImplemented) {
11219 Py_LeaveRecursiveCall();
11221 if (unlikely(result == NULL)) {
11222 return NUITKA_BOOL_EXCEPTION;
11226 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11232 Py_DECREF_IMMORTAL(result);
11236 cmpfunc fcmp = NULL;
11238 if (fcmp != NULL) {
11239 int c = (*fcmp)(operand1, operand2);
11240 c = adjust_tp_compare(c);
11242 Py_LeaveRecursiveCall();
11245 return NUITKA_BOOL_EXCEPTION;
11268 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
11272 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11281 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
11282 f = TP_RICHCOMPARE(type2);
11285 PyObject *result = (*f)(operand2, operand1, Py_LT);
11287 if (result != Py_NotImplemented) {
11288 Py_LeaveRecursiveCall();
11290 if (unlikely(result == NULL)) {
11291 return NUITKA_BOOL_EXCEPTION;
11295 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11301 Py_DECREF_IMMORTAL(result);
11305 f = PyList_Type.tp_richcompare;
11307 PyObject *result = (*f)(operand1, operand2, Py_GT);
11309 if (result != Py_NotImplemented) {
11310 Py_LeaveRecursiveCall();
11312 if (unlikely(result == NULL)) {
11313 return NUITKA_BOOL_EXCEPTION;
11317 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11323 Py_DECREF_IMMORTAL(result);
11326 f = TP_RICHCOMPARE(type2);
11328 PyObject *result = (*f)(operand2, operand1, Py_LT);
11330 if (result != Py_NotImplemented) {
11331 Py_LeaveRecursiveCall();
11333 if (unlikely(result == NULL)) {
11334 return NUITKA_BOOL_EXCEPTION;
11338 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11344 Py_DECREF_IMMORTAL(result);
11350 cmpfunc fcmp = NULL;
11351 c = (*fcmp)(operand1, operand2);
11352 }
else if (PyInstance_Check(operand2)) {
11353 cmpfunc fcmp = type2->tp_compare;
11354 c = (*fcmp)(operand1, operand2);
11356 c = try_3way_compare(operand1, operand2);
11360 if (&PyList_Type == type2) {
11361 Py_uintptr_t aa = (Py_uintptr_t)operand1;
11362 Py_uintptr_t bb = (Py_uintptr_t)operand2;
11364 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11365 }
else if (operand1 == Py_None) {
11368 }
else if (operand2 == Py_None) {
11371 }
else if (PyNumber_Check(operand1)) {
11374 if (PyNumber_Check(operand2)) {
11376 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
11377 Py_uintptr_t bb = (Py_uintptr_t)type2;
11379 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11383 }
else if (PyNumber_Check(operand2)) {
11387 int s = strcmp(
"list", type2->tp_name);
11391 }
else if (s > 0) {
11395 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
11396 Py_uintptr_t bb = (Py_uintptr_t)type2;
11398 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11403 Py_LeaveRecursiveCall();
11405 if (unlikely(c <= -2)) {
11406 return NUITKA_BOOL_EXCEPTION;
11431 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11435 bool checked_reverse_op =
false;
11438 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
11439 f = TP_RICHCOMPARE(type2);
11442 checked_reverse_op =
true;
11444 PyObject *result = (*f)(operand2, operand1, Py_LT);
11446 if (result != Py_NotImplemented) {
11447 Py_LeaveRecursiveCall();
11449 if (unlikely(result == NULL)) {
11450 return NUITKA_BOOL_EXCEPTION;
11454 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11460 Py_DECREF_IMMORTAL(result);
11464 f = PyList_Type.tp_richcompare;
11467 PyObject *result = (*f)(operand1, operand2, Py_GT);
11469 if (result != Py_NotImplemented) {
11470 Py_LeaveRecursiveCall();
11472 if (unlikely(result == NULL)) {
11473 return NUITKA_BOOL_EXCEPTION;
11477 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11483 Py_DECREF_IMMORTAL(result);
11486 if (checked_reverse_op ==
false) {
11487 f = TP_RICHCOMPARE(type2);
11490 PyObject *result = (*f)(operand2, operand1, Py_LT);
11492 if (result != Py_NotImplemented) {
11493 Py_LeaveRecursiveCall();
11495 if (unlikely(result == NULL)) {
11496 return NUITKA_BOOL_EXCEPTION;
11500 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11506 Py_DECREF_IMMORTAL(result);
11510 Py_LeaveRecursiveCall();
11516 bool r = operand1 == operand2;
11517 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11522 bool r = operand1 != operand2;
11523 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11528#if PYTHON_VERSION < 0x360
11529 PyErr_Format(PyExc_TypeError,
"unorderable types: list() > %s()", type2->tp_name);
11531 PyErr_Format(PyExc_TypeError,
"'>' not supported between instances of 'list' and '%s'", type2->tp_name);
11533 return NUITKA_BOOL_EXCEPTION;
11539nuitka_bool RICH_COMPARE_GT_NBOOL_LIST_LIST(PyObject *operand1, PyObject *operand2) {
11541 return COMPARE_GT_NBOOL_LIST_LIST(operand1, operand2);
11544static PyObject *COMPARE_GT_OBJECT_LONG_CLONG(PyObject *operand1,
long operand2) {
11545 CHECK_OBJECT(operand1);
11546 assert(PyLong_CheckExact(operand1));
11548 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11550 bool operand2_is_negative;
11551 unsigned long operand2_abs_ival;
11553 if (operand2 < 0) {
11554 operand2_abs_ival = (
unsigned long)(-1 - operand2) + 1;
11555 operand2_is_negative =
true;
11557 operand2_abs_ival = (
unsigned long)operand2;
11558 operand2_is_negative =
false;
11561 Py_ssize_t operand2_digit_count = 0;
11562 digit operand2_digits[5] = {0};
11564 unsigned long t = operand2_abs_ival;
11567 operand2_digit_count += 1;
11568 assert(operand2_digit_count <= (Py_ssize_t)(
sizeof(operand2_digit_count) /
sizeof(digit)));
11570 operand2_digits[operand2_digit_count] = (digit)(t & PyLong_MASK);
11571 t >>= PyLong_SHIFT;
11575 NUITKA_MAY_BE_UNUSED Py_ssize_t operand2_size =
11576 operand2_is_negative ==
false ? operand2_digit_count : -operand2_digit_count;
11580 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) != operand2_size) {
11581 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - operand2_size > 0;
11583 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11586 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != operand2_digits[i]) {
11587 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] > operand2_digits[i];
11588 if (Nuitka_LongIsNegative(operand1_long_object)) {
11597 PyObject *result = BOOL_FROM(r);
11598 Py_INCREF_IMMORTAL(result);
11601#if PYTHON_VERSION < 0x300
11603PyObject *RICH_COMPARE_GT_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
11605 return COMPARE_GT_OBJECT_LONG_CLONG(operand1, PyInt_AS_LONG(operand1));
11609static bool COMPARE_GT_CBOOL_LONG_CLONG(PyObject *operand1,
long operand2) {
11610 CHECK_OBJECT(operand1);
11611 assert(PyLong_CheckExact(operand1));
11613 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11615 bool operand2_is_negative;
11616 unsigned long operand2_abs_ival;
11618 if (operand2 < 0) {
11619 operand2_abs_ival = (
unsigned long)(-1 - operand2) + 1;
11620 operand2_is_negative =
true;
11622 operand2_abs_ival = (
unsigned long)operand2;
11623 operand2_is_negative =
false;
11626 Py_ssize_t operand2_digit_count = 0;
11627 digit operand2_digits[5] = {0};
11629 unsigned long t = operand2_abs_ival;
11632 operand2_digit_count += 1;
11633 assert(operand2_digit_count <= (Py_ssize_t)(
sizeof(operand2_digit_count) /
sizeof(digit)));
11635 operand2_digits[operand2_digit_count] = (digit)(t & PyLong_MASK);
11636 t >>= PyLong_SHIFT;
11640 NUITKA_MAY_BE_UNUSED Py_ssize_t operand2_size =
11641 operand2_is_negative ==
false ? operand2_digit_count : -operand2_digit_count;
11645 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) != operand2_size) {
11646 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - operand2_size > 0;
11648 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11651 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != operand2_digits[i]) {
11652 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] > operand2_digits[i];
11653 if (Nuitka_LongIsNegative(operand1_long_object)) {
11666#if PYTHON_VERSION < 0x300
11668bool RICH_COMPARE_GT_CBOOL_LONG_INT(PyObject *operand1, PyObject *operand2) {
11670 return COMPARE_GT_CBOOL_LONG_CLONG(operand1, PyInt_AS_LONG(operand1));
11674#if PYTHON_VERSION < 0x300
11675static PyObject *COMPARE_GT_OBJECT_INT_CLONG(PyObject *operand1,
long operand2) {
11676 CHECK_OBJECT(operand1);
11677 assert(PyInt_CheckExact(operand1));
11679 const long a = PyInt_AS_LONG(operand1);
11680 const long b = operand2;
11685 PyObject *result = BOOL_FROM(r);
11686 Py_INCREF_IMMORTAL(result);
11690#if PYTHON_VERSION < 0x300
11692PyObject *RICH_COMPARE_GT_OBJECT_INT_CLONG(PyObject *operand1,
long operand2) {
11694 return COMPARE_GT_OBJECT_INT_CLONG(operand1, operand2);
11698#if PYTHON_VERSION < 0x300
11699static bool COMPARE_GT_CBOOL_INT_CLONG(PyObject *operand1,
long operand2) {
11700 CHECK_OBJECT(operand1);
11701 assert(PyInt_CheckExact(operand1));
11703 const long a = PyInt_AS_LONG(operand1);
11704 const long b = operand2;
11714#if PYTHON_VERSION < 0x300
11716bool RICH_COMPARE_GT_CBOOL_INT_CLONG(PyObject *operand1,
long operand2) {
11718 return COMPARE_GT_CBOOL_INT_CLONG(operand1, operand2);
11722static PyObject *COMPARE_GT_OBJECT_LONG_DIGIT(PyObject *operand1,
long operand2) {
11723 CHECK_OBJECT(operand1);
11724 assert(PyLong_CheckExact(operand1));
11725 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
11727 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11731 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
11732 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1))) {
11733 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) -
11734 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1)) >
11737 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11740 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != (digit)Py_ABS(operand2)) {
11741 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] > (digit)Py_ABS(operand2);
11742 if (Nuitka_LongIsNegative(operand1_long_object)) {
11751 PyObject *result = BOOL_FROM(r);
11752 Py_INCREF_IMMORTAL(result);
11757PyObject *RICH_COMPARE_GT_OBJECT_LONG_DIGIT(PyObject *operand1,
long operand2) {
11759 return COMPARE_GT_OBJECT_LONG_DIGIT(operand1, operand2);
11762static bool COMPARE_GT_CBOOL_LONG_DIGIT(PyObject *operand1,
long operand2) {
11763 CHECK_OBJECT(operand1);
11764 assert(PyLong_CheckExact(operand1));
11765 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
11767 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11771 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
11772 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1))) {
11773 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) -
11774 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1)) >
11777 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11780 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != (digit)Py_ABS(operand2)) {
11781 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] > (digit)Py_ABS(operand2);
11782 if (Nuitka_LongIsNegative(operand1_long_object)) {
11797bool RICH_COMPARE_GT_CBOOL_LONG_DIGIT(PyObject *operand1,
long operand2) {
11799 return COMPARE_GT_CBOOL_LONG_DIGIT(operand1, operand2);
11802static PyObject *COMPARE_GT_OBJECT_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11803 CHECK_OBJECT(operand1);
11804 assert(PyFloat_CheckExact(operand1));
11806 const double a = PyFloat_AS_DOUBLE(operand1);
11807 const double b = operand2;
11812 PyObject *result = BOOL_FROM(r);
11813 Py_INCREF_IMMORTAL(result);
11817PyObject *RICH_COMPARE_GT_OBJECT_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11819 return COMPARE_GT_OBJECT_FLOAT_CFLOAT(operand1, operand2);
11822static bool COMPARE_GT_CBOOL_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11823 CHECK_OBJECT(operand1);
11824 assert(PyFloat_CheckExact(operand1));
11826 const double a = PyFloat_AS_DOUBLE(operand1);
11827 const double b = operand2;
11837bool RICH_COMPARE_GT_CBOOL_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11839 return COMPARE_GT_CBOOL_FLOAT_CFLOAT(operand1, operand2);