7#include "nuitka/prelude.h"
12#if PYTHON_VERSION < 0x300
13static PyObject *COMPARE_LE_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_LE_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_LE_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
51#if PYTHON_VERSION < 0x300
52 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
53 return COMPARE_LE_OBJECT_INT_INT(operand1, operand2);
58 if (operand1 == operand2 && IS_SANE_TYPE(Py_TYPE(operand1))) {
60 PyObject *result = BOOL_FROM(r);
61 Py_INCREF_IMMORTAL(result);
65#if PYTHON_VERSION < 0x300
66 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
70 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
75 PyTypeObject *type1 = Py_TYPE(operand1);
76 PyTypeObject *type2 = Py_TYPE(operand2);
78#if PYTHON_VERSION < 0x300
80 if (type1 == type2 && !PyInstance_Check(operand1)) {
82 richcmpfunc frich = TP_RICHCOMPARE(type1);
85 PyObject *result = (*frich)(operand1, operand2, Py_LE);
87 if (result != Py_NotImplemented) {
88 Py_LeaveRecursiveCall();
93 Py_DECREF_IMMORTAL(result);
97 cmpfunc fcmp = type1->tp_compare;
100 int c = (*fcmp)(operand1, operand2);
101 c = adjust_tp_compare(c);
103 Py_LeaveRecursiveCall();
129 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
133 PyObject *result = BOOL_FROM(r);
134 Py_INCREF_IMMORTAL(result);
142 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
143 f = TP_RICHCOMPARE(type2);
146 PyObject *result = (*f)(operand2, operand1, Py_GE);
148 if (result != Py_NotImplemented) {
149 Py_LeaveRecursiveCall();
154 Py_DECREF_IMMORTAL(result);
158 f = TP_RICHCOMPARE(type1);
160 PyObject *result = (*f)(operand1, operand2, Py_LE);
162 if (result != Py_NotImplemented) {
163 Py_LeaveRecursiveCall();
168 Py_DECREF_IMMORTAL(result);
171 f = TP_RICHCOMPARE(type2);
173 PyObject *result = (*f)(operand2, operand1, Py_GE);
175 if (result != Py_NotImplemented) {
176 Py_LeaveRecursiveCall();
181 Py_DECREF_IMMORTAL(result);
186 if (PyInstance_Check(operand1)) {
187 cmpfunc fcmp = type1->tp_compare;
188 c = (*fcmp)(operand1, operand2);
189 }
else if (PyInstance_Check(operand2)) {
190 cmpfunc fcmp = type2->tp_compare;
191 c = (*fcmp)(operand1, operand2);
193 c = try_3way_compare(operand1, operand2);
197 if (type1 == type2) {
198 Py_uintptr_t aa = (Py_uintptr_t)operand1;
199 Py_uintptr_t bb = (Py_uintptr_t)operand2;
201 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
202 }
else if (operand1 == Py_None) {
205 }
else if (operand2 == Py_None) {
208 }
else if (PyNumber_Check(operand1)) {
211 if (PyNumber_Check(operand2)) {
213 Py_uintptr_t aa = (Py_uintptr_t)type1;
214 Py_uintptr_t bb = (Py_uintptr_t)type2;
216 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
220 }
else if (PyNumber_Check(operand2)) {
224 int s = strcmp(type1->tp_name, type2->tp_name);
232 Py_uintptr_t aa = (Py_uintptr_t)type1;
233 Py_uintptr_t bb = (Py_uintptr_t)type2;
235 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
240 Py_LeaveRecursiveCall();
242 if (unlikely(c <= -2)) {
268 PyObject *result = BOOL_FROM(r);
269 Py_INCREF_IMMORTAL(result);
272 bool checked_reverse_op =
false;
275 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
276 f = TP_RICHCOMPARE(type2);
279 checked_reverse_op =
true;
281 PyObject *result = (*f)(operand2, operand1, Py_GE);
283 if (result != Py_NotImplemented) {
284 Py_LeaveRecursiveCall();
289 Py_DECREF_IMMORTAL(result);
293 f = TP_RICHCOMPARE(type1);
296 PyObject *result = (*f)(operand1, operand2, Py_LE);
298 if (result != Py_NotImplemented) {
299 Py_LeaveRecursiveCall();
304 Py_DECREF_IMMORTAL(result);
307 if (checked_reverse_op ==
false) {
308 f = TP_RICHCOMPARE(type2);
311 PyObject *result = (*f)(operand2, operand1, Py_GE);
313 if (result != Py_NotImplemented) {
314 Py_LeaveRecursiveCall();
319 Py_DECREF_IMMORTAL(result);
323 Py_LeaveRecursiveCall();
329 bool r = operand1 == operand2;
330 PyObject *result = BOOL_FROM(r);
331 Py_INCREF_IMMORTAL(result);
335 bool r = operand1 != operand2;
336 PyObject *result = BOOL_FROM(r);
337 Py_INCREF_IMMORTAL(result);
341#if PYTHON_VERSION < 0x360
342 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= %s()", type1->tp_name, type2->tp_name);
344 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and '%s'", type1->tp_name,
353nuitka_bool RICH_COMPARE_LE_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
355#if PYTHON_VERSION < 0x300
356 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
357 return COMPARE_LE_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
362 if (operand1 == operand2 && IS_SANE_TYPE(Py_TYPE(operand1))) {
364 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
369#if PYTHON_VERSION < 0x300
370 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
371 return NUITKA_BOOL_EXCEPTION;
374 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
375 return NUITKA_BOOL_EXCEPTION;
379 PyTypeObject *type1 = Py_TYPE(operand1);
380 PyTypeObject *type2 = Py_TYPE(operand2);
382#if PYTHON_VERSION < 0x300
384 if (type1 == type2 && !PyInstance_Check(operand1)) {
386 richcmpfunc frich = TP_RICHCOMPARE(type1);
389 PyObject *result = (*frich)(operand1, operand2, Py_LE);
391 if (result != Py_NotImplemented) {
392 Py_LeaveRecursiveCall();
394 if (unlikely(result == NULL)) {
395 return NUITKA_BOOL_EXCEPTION;
399 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
405 Py_DECREF_IMMORTAL(result);
409 cmpfunc fcmp = type1->tp_compare;
412 int c = (*fcmp)(operand1, operand2);
413 c = adjust_tp_compare(c);
415 Py_LeaveRecursiveCall();
418 return NUITKA_BOOL_EXCEPTION;
441 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
445 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
454 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
455 f = TP_RICHCOMPARE(type2);
458 PyObject *result = (*f)(operand2, operand1, Py_GE);
460 if (result != Py_NotImplemented) {
461 Py_LeaveRecursiveCall();
463 if (unlikely(result == NULL)) {
464 return NUITKA_BOOL_EXCEPTION;
468 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
474 Py_DECREF_IMMORTAL(result);
478 f = TP_RICHCOMPARE(type1);
480 PyObject *result = (*f)(operand1, operand2, Py_LE);
482 if (result != Py_NotImplemented) {
483 Py_LeaveRecursiveCall();
485 if (unlikely(result == NULL)) {
486 return NUITKA_BOOL_EXCEPTION;
490 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
496 Py_DECREF_IMMORTAL(result);
499 f = TP_RICHCOMPARE(type2);
501 PyObject *result = (*f)(operand2, operand1, Py_GE);
503 if (result != Py_NotImplemented) {
504 Py_LeaveRecursiveCall();
506 if (unlikely(result == NULL)) {
507 return NUITKA_BOOL_EXCEPTION;
511 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
517 Py_DECREF_IMMORTAL(result);
522 if (PyInstance_Check(operand1)) {
523 cmpfunc fcmp = type1->tp_compare;
524 c = (*fcmp)(operand1, operand2);
525 }
else if (PyInstance_Check(operand2)) {
526 cmpfunc fcmp = type2->tp_compare;
527 c = (*fcmp)(operand1, operand2);
529 c = try_3way_compare(operand1, operand2);
533 if (type1 == type2) {
534 Py_uintptr_t aa = (Py_uintptr_t)operand1;
535 Py_uintptr_t bb = (Py_uintptr_t)operand2;
537 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
538 }
else if (operand1 == Py_None) {
541 }
else if (operand2 == Py_None) {
544 }
else if (PyNumber_Check(operand1)) {
547 if (PyNumber_Check(operand2)) {
549 Py_uintptr_t aa = (Py_uintptr_t)type1;
550 Py_uintptr_t bb = (Py_uintptr_t)type2;
552 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
556 }
else if (PyNumber_Check(operand2)) {
560 int s = strcmp(type1->tp_name, type2->tp_name);
568 Py_uintptr_t aa = (Py_uintptr_t)type1;
569 Py_uintptr_t bb = (Py_uintptr_t)type2;
571 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
576 Py_LeaveRecursiveCall();
578 if (unlikely(c <= -2)) {
579 return NUITKA_BOOL_EXCEPTION;
604 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
608 bool checked_reverse_op =
false;
611 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
612 f = TP_RICHCOMPARE(type2);
615 checked_reverse_op =
true;
617 PyObject *result = (*f)(operand2, operand1, Py_GE);
619 if (result != Py_NotImplemented) {
620 Py_LeaveRecursiveCall();
622 if (unlikely(result == NULL)) {
623 return NUITKA_BOOL_EXCEPTION;
627 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
633 Py_DECREF_IMMORTAL(result);
637 f = TP_RICHCOMPARE(type1);
640 PyObject *result = (*f)(operand1, operand2, Py_LE);
642 if (result != Py_NotImplemented) {
643 Py_LeaveRecursiveCall();
645 if (unlikely(result == NULL)) {
646 return NUITKA_BOOL_EXCEPTION;
650 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
656 Py_DECREF_IMMORTAL(result);
659 if (checked_reverse_op ==
false) {
660 f = TP_RICHCOMPARE(type2);
663 PyObject *result = (*f)(operand2, operand1, Py_GE);
665 if (result != Py_NotImplemented) {
666 Py_LeaveRecursiveCall();
668 if (unlikely(result == NULL)) {
669 return NUITKA_BOOL_EXCEPTION;
673 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
679 Py_DECREF_IMMORTAL(result);
683 Py_LeaveRecursiveCall();
689 bool r = operand1 == operand2;
690 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
695 bool r = operand1 != operand2;
696 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
701#if PYTHON_VERSION < 0x360
702 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= %s()", type1->tp_name, type2->tp_name);
704 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and '%s'", type1->tp_name,
707 return NUITKA_BOOL_EXCEPTION;
712#if PYTHON_VERSION < 0x300
713static PyObject *COMPARE_LE_OBJECT_STR_STR(PyObject *operand1, PyObject *operand2) {
714 CHECK_OBJECT(operand1);
715 assert(PyString_CheckExact(operand1));
716 CHECK_OBJECT(operand2);
717 assert(PyString_CheckExact(operand2));
719 PyStringObject *a = (PyStringObject *)operand1;
720 PyStringObject *b = (PyStringObject *)operand2;
723 if (operand1 == operand2) {
727 PyObject *result = BOOL_FROM(r);
728 Py_INCREF_IMMORTAL(result);
732 Py_ssize_t len_a = Py_SIZE(operand1);
733 Py_ssize_t len_b = Py_SIZE(operand2);
735 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
739 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
742 c = memcmp(a->ob_sval, b->ob_sval, min_len);
749 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
755 PyObject *result = BOOL_FROM(c != 0);
756 Py_INCREF_IMMORTAL(result);
760#if PYTHON_VERSION < 0x300
762PyObject *RICH_COMPARE_LE_OBJECT_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
764 if (Py_TYPE(operand1) == &PyString_Type) {
765 return COMPARE_LE_OBJECT_STR_STR(operand1, operand2);
768#if PYTHON_VERSION < 0x300
769 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
773 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
778 PyTypeObject *type1 = Py_TYPE(operand1);
780#if PYTHON_VERSION < 0x300
782 if (type1 == &PyString_Type && !0) {
784 richcmpfunc frich = PyString_Type.tp_richcompare;
787 PyObject *result = (*frich)(operand1, operand2, Py_LE);
789 if (result != Py_NotImplemented) {
790 Py_LeaveRecursiveCall();
795 Py_DECREF_IMMORTAL(result);
802 int c = (*fcmp)(operand1, operand2);
803 c = adjust_tp_compare(c);
805 Py_LeaveRecursiveCall();
831 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
835 PyObject *result = BOOL_FROM(r);
836 Py_INCREF_IMMORTAL(result);
844 if (type1 != &PyString_Type && 0) {
845 f = PyString_Type.tp_richcompare;
848 PyObject *result = (*f)(operand2, operand1, Py_GE);
850 if (result != Py_NotImplemented) {
851 Py_LeaveRecursiveCall();
856 Py_DECREF_IMMORTAL(result);
860 f = TP_RICHCOMPARE(type1);
862 PyObject *result = (*f)(operand1, operand2, Py_LE);
864 if (result != Py_NotImplemented) {
865 Py_LeaveRecursiveCall();
870 Py_DECREF_IMMORTAL(result);
873 f = PyString_Type.tp_richcompare;
875 PyObject *result = (*f)(operand2, operand1, Py_GE);
877 if (result != Py_NotImplemented) {
878 Py_LeaveRecursiveCall();
883 Py_DECREF_IMMORTAL(result);
888 if (PyInstance_Check(operand1)) {
889 cmpfunc fcmp = type1->tp_compare;
890 c = (*fcmp)(operand1, operand2);
893 c = (*fcmp)(operand1, operand2);
895 c = try_3way_compare(operand1, operand2);
899 if (type1 == &PyString_Type) {
900 Py_uintptr_t aa = (Py_uintptr_t)operand1;
901 Py_uintptr_t bb = (Py_uintptr_t)operand2;
903 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
904 }
else if (operand1 == Py_None) {
907 }
else if (operand2 == Py_None) {
910 }
else if (PyNumber_Check(operand1)) {
913 if (PyNumber_Check(operand2)) {
915 Py_uintptr_t aa = (Py_uintptr_t)type1;
916 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
918 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
922 }
else if (PyNumber_Check(operand2)) {
926 int s = strcmp(type1->tp_name,
"str");
934 Py_uintptr_t aa = (Py_uintptr_t)type1;
935 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
937 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
942 Py_LeaveRecursiveCall();
944 if (unlikely(c <= -2)) {
970 PyObject *result = BOOL_FROM(r);
971 Py_INCREF_IMMORTAL(result);
974 bool checked_reverse_op =
false;
977 if (type1 != &PyString_Type && Nuitka_Type_IsSubtype(&PyString_Type, type1)) {
978 f = PyString_Type.tp_richcompare;
981 checked_reverse_op =
true;
983 PyObject *result = (*f)(operand2, operand1, Py_GE);
985 if (result != Py_NotImplemented) {
986 Py_LeaveRecursiveCall();
991 Py_DECREF_IMMORTAL(result);
995 f = TP_RICHCOMPARE(type1);
998 PyObject *result = (*f)(operand1, operand2, Py_LE);
1000 if (result != Py_NotImplemented) {
1001 Py_LeaveRecursiveCall();
1006 Py_DECREF_IMMORTAL(result);
1009 if (checked_reverse_op ==
false) {
1010 f = PyString_Type.tp_richcompare;
1013 PyObject *result = (*f)(operand2, operand1, Py_GE);
1015 if (result != Py_NotImplemented) {
1016 Py_LeaveRecursiveCall();
1021 Py_DECREF_IMMORTAL(result);
1025 Py_LeaveRecursiveCall();
1031 bool r = operand1 == operand2;
1032 PyObject *result = BOOL_FROM(r);
1033 Py_INCREF_IMMORTAL(result);
1037 bool r = operand1 != operand2;
1038 PyObject *result = BOOL_FROM(r);
1039 Py_INCREF_IMMORTAL(result);
1043#if PYTHON_VERSION < 0x360
1044 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= str()", type1->tp_name);
1046 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'str'", type1->tp_name);
1054#if PYTHON_VERSION < 0x300
1056PyObject *RICH_COMPARE_LE_OBJECT_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
1058 if (&PyString_Type == Py_TYPE(operand2)) {
1059 return COMPARE_LE_OBJECT_STR_STR(operand1, operand2);
1062#if PYTHON_VERSION < 0x300
1063 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1067 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1072 PyTypeObject *type2 = Py_TYPE(operand2);
1074#if PYTHON_VERSION < 0x300
1076 if (&PyString_Type == type2 && !0) {
1078 richcmpfunc frich = PyString_Type.tp_richcompare;
1080 if (frich != NULL) {
1081 PyObject *result = (*frich)(operand1, operand2, Py_LE);
1083 if (result != Py_NotImplemented) {
1084 Py_LeaveRecursiveCall();
1089 Py_DECREF_IMMORTAL(result);
1093 cmpfunc fcmp = NULL;
1096 int c = (*fcmp)(operand1, operand2);
1097 c = adjust_tp_compare(c);
1099 Py_LeaveRecursiveCall();
1125 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1129 PyObject *result = BOOL_FROM(r);
1130 Py_INCREF_IMMORTAL(result);
1138 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1139 f = TP_RICHCOMPARE(type2);
1142 PyObject *result = (*f)(operand2, operand1, Py_GE);
1144 if (result != Py_NotImplemented) {
1145 Py_LeaveRecursiveCall();
1150 Py_DECREF_IMMORTAL(result);
1154 f = PyString_Type.tp_richcompare;
1156 PyObject *result = (*f)(operand1, operand2, Py_LE);
1158 if (result != Py_NotImplemented) {
1159 Py_LeaveRecursiveCall();
1164 Py_DECREF_IMMORTAL(result);
1167 f = TP_RICHCOMPARE(type2);
1169 PyObject *result = (*f)(operand2, operand1, Py_GE);
1171 if (result != Py_NotImplemented) {
1172 Py_LeaveRecursiveCall();
1177 Py_DECREF_IMMORTAL(result);
1183 cmpfunc fcmp = NULL;
1184 c = (*fcmp)(operand1, operand2);
1185 }
else if (PyInstance_Check(operand2)) {
1186 cmpfunc fcmp = type2->tp_compare;
1187 c = (*fcmp)(operand1, operand2);
1189 c = try_3way_compare(operand1, operand2);
1193 if (&PyString_Type == type2) {
1194 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1195 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1197 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1198 }
else if (operand1 == Py_None) {
1201 }
else if (operand2 == Py_None) {
1204 }
else if (PyNumber_Check(operand1)) {
1207 if (PyNumber_Check(operand2)) {
1209 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1210 Py_uintptr_t bb = (Py_uintptr_t)type2;
1212 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1216 }
else if (PyNumber_Check(operand2)) {
1220 int s = strcmp(
"str", type2->tp_name);
1228 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1229 Py_uintptr_t bb = (Py_uintptr_t)type2;
1231 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1236 Py_LeaveRecursiveCall();
1238 if (unlikely(c <= -2)) {
1264 PyObject *result = BOOL_FROM(r);
1265 Py_INCREF_IMMORTAL(result);
1268 bool checked_reverse_op =
false;
1271 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1272 f = TP_RICHCOMPARE(type2);
1275 checked_reverse_op =
true;
1277 PyObject *result = (*f)(operand2, operand1, Py_GE);
1279 if (result != Py_NotImplemented) {
1280 Py_LeaveRecursiveCall();
1285 Py_DECREF_IMMORTAL(result);
1289 f = PyString_Type.tp_richcompare;
1292 PyObject *result = (*f)(operand1, operand2, Py_LE);
1294 if (result != Py_NotImplemented) {
1295 Py_LeaveRecursiveCall();
1300 Py_DECREF_IMMORTAL(result);
1303 if (checked_reverse_op ==
false) {
1304 f = TP_RICHCOMPARE(type2);
1307 PyObject *result = (*f)(operand2, operand1, Py_GE);
1309 if (result != Py_NotImplemented) {
1310 Py_LeaveRecursiveCall();
1315 Py_DECREF_IMMORTAL(result);
1319 Py_LeaveRecursiveCall();
1325 bool r = operand1 == operand2;
1326 PyObject *result = BOOL_FROM(r);
1327 Py_INCREF_IMMORTAL(result);
1331 bool r = operand1 != operand2;
1332 PyObject *result = BOOL_FROM(r);
1333 Py_INCREF_IMMORTAL(result);
1337#if PYTHON_VERSION < 0x360
1338 PyErr_Format(PyExc_TypeError,
"unorderable types: str() <= %s()", type2->tp_name);
1340 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'str' and '%s'", type2->tp_name);
1348#if PYTHON_VERSION < 0x300
1350PyObject *RICH_COMPARE_LE_OBJECT_STR_STR(PyObject *operand1, PyObject *operand2) {
1352 return COMPARE_LE_OBJECT_STR_STR(operand1, operand2);
1356#if PYTHON_VERSION < 0x300
1357static bool COMPARE_LE_CBOOL_STR_STR(PyObject *operand1, PyObject *operand2) {
1358 CHECK_OBJECT(operand1);
1359 assert(PyString_CheckExact(operand1));
1360 CHECK_OBJECT(operand2);
1361 assert(PyString_CheckExact(operand2));
1363 PyStringObject *a = (PyStringObject *)operand1;
1364 PyStringObject *b = (PyStringObject *)operand2;
1367 if (operand1 == operand2) {
1376 Py_ssize_t len_a = Py_SIZE(operand1);
1377 Py_ssize_t len_b = Py_SIZE(operand2);
1379 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
1383 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
1386 c = memcmp(a->ob_sval, b->ob_sval, min_len);
1393 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
1399 bool result = c != 0;
1404#if PYTHON_VERSION < 0x300
1406bool RICH_COMPARE_LE_CBOOL_STR_STR(PyObject *operand1, PyObject *operand2) {
1408 return COMPARE_LE_CBOOL_STR_STR(operand1, operand2);
1412#if PYTHON_VERSION < 0x300
1414nuitka_bool RICH_COMPARE_LE_NBOOL_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
1416 if (Py_TYPE(operand1) == &PyString_Type) {
1417 return COMPARE_LE_CBOOL_STR_STR(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1420#if PYTHON_VERSION < 0x300
1421 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1422 return NUITKA_BOOL_EXCEPTION;
1425 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1426 return NUITKA_BOOL_EXCEPTION;
1430 PyTypeObject *type1 = Py_TYPE(operand1);
1432#if PYTHON_VERSION < 0x300
1434 if (type1 == &PyString_Type && !0) {
1436 richcmpfunc frich = PyString_Type.tp_richcompare;
1438 if (frich != NULL) {
1439 PyObject *result = (*frich)(operand1, operand2, Py_LE);
1441 if (result != Py_NotImplemented) {
1442 Py_LeaveRecursiveCall();
1444 if (unlikely(result == NULL)) {
1445 return NUITKA_BOOL_EXCEPTION;
1449 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1455 Py_DECREF_IMMORTAL(result);
1459 cmpfunc fcmp = NULL;
1462 int c = (*fcmp)(operand1, operand2);
1463 c = adjust_tp_compare(c);
1465 Py_LeaveRecursiveCall();
1468 return NUITKA_BOOL_EXCEPTION;
1491 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1495 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1504 if (type1 != &PyString_Type && 0) {
1505 f = PyString_Type.tp_richcompare;
1508 PyObject *result = (*f)(operand2, operand1, Py_GE);
1510 if (result != Py_NotImplemented) {
1511 Py_LeaveRecursiveCall();
1513 if (unlikely(result == NULL)) {
1514 return NUITKA_BOOL_EXCEPTION;
1518 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1524 Py_DECREF_IMMORTAL(result);
1528 f = TP_RICHCOMPARE(type1);
1530 PyObject *result = (*f)(operand1, operand2, Py_LE);
1532 if (result != Py_NotImplemented) {
1533 Py_LeaveRecursiveCall();
1535 if (unlikely(result == NULL)) {
1536 return NUITKA_BOOL_EXCEPTION;
1540 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1546 Py_DECREF_IMMORTAL(result);
1549 f = PyString_Type.tp_richcompare;
1551 PyObject *result = (*f)(operand2, operand1, Py_GE);
1553 if (result != Py_NotImplemented) {
1554 Py_LeaveRecursiveCall();
1556 if (unlikely(result == NULL)) {
1557 return NUITKA_BOOL_EXCEPTION;
1561 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1567 Py_DECREF_IMMORTAL(result);
1572 if (PyInstance_Check(operand1)) {
1573 cmpfunc fcmp = type1->tp_compare;
1574 c = (*fcmp)(operand1, operand2);
1576 cmpfunc fcmp = NULL;
1577 c = (*fcmp)(operand1, operand2);
1579 c = try_3way_compare(operand1, operand2);
1583 if (type1 == &PyString_Type) {
1584 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1585 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1587 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1588 }
else if (operand1 == Py_None) {
1591 }
else if (operand2 == Py_None) {
1594 }
else if (PyNumber_Check(operand1)) {
1597 if (PyNumber_Check(operand2)) {
1599 Py_uintptr_t aa = (Py_uintptr_t)type1;
1600 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
1602 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1606 }
else if (PyNumber_Check(operand2)) {
1610 int s = strcmp(type1->tp_name,
"str");
1618 Py_uintptr_t aa = (Py_uintptr_t)type1;
1619 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
1621 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1626 Py_LeaveRecursiveCall();
1628 if (unlikely(c <= -2)) {
1629 return NUITKA_BOOL_EXCEPTION;
1654 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1658 bool checked_reverse_op =
false;
1661 if (type1 != &PyString_Type && Nuitka_Type_IsSubtype(&PyString_Type, type1)) {
1662 f = PyString_Type.tp_richcompare;
1665 checked_reverse_op =
true;
1667 PyObject *result = (*f)(operand2, operand1, Py_GE);
1669 if (result != Py_NotImplemented) {
1670 Py_LeaveRecursiveCall();
1672 if (unlikely(result == NULL)) {
1673 return NUITKA_BOOL_EXCEPTION;
1677 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1683 Py_DECREF_IMMORTAL(result);
1687 f = TP_RICHCOMPARE(type1);
1690 PyObject *result = (*f)(operand1, operand2, Py_LE);
1692 if (result != Py_NotImplemented) {
1693 Py_LeaveRecursiveCall();
1695 if (unlikely(result == NULL)) {
1696 return NUITKA_BOOL_EXCEPTION;
1700 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1706 Py_DECREF_IMMORTAL(result);
1709 if (checked_reverse_op ==
false) {
1710 f = PyString_Type.tp_richcompare;
1713 PyObject *result = (*f)(operand2, operand1, Py_GE);
1715 if (result != Py_NotImplemented) {
1716 Py_LeaveRecursiveCall();
1718 if (unlikely(result == NULL)) {
1719 return NUITKA_BOOL_EXCEPTION;
1723 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1729 Py_DECREF_IMMORTAL(result);
1733 Py_LeaveRecursiveCall();
1739 bool r = operand1 == operand2;
1740 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1745 bool r = operand1 != operand2;
1746 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1751#if PYTHON_VERSION < 0x360
1752 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= str()", type1->tp_name);
1754 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'str'", type1->tp_name);
1756 return NUITKA_BOOL_EXCEPTION;
1762#if PYTHON_VERSION < 0x300
1764nuitka_bool RICH_COMPARE_LE_NBOOL_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
1766 if (&PyString_Type == Py_TYPE(operand2)) {
1767 return COMPARE_LE_CBOOL_STR_STR(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1770#if PYTHON_VERSION < 0x300
1771 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1772 return NUITKA_BOOL_EXCEPTION;
1775 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1776 return NUITKA_BOOL_EXCEPTION;
1780 PyTypeObject *type2 = Py_TYPE(operand2);
1782#if PYTHON_VERSION < 0x300
1784 if (&PyString_Type == type2 && !0) {
1786 richcmpfunc frich = PyString_Type.tp_richcompare;
1788 if (frich != NULL) {
1789 PyObject *result = (*frich)(operand1, operand2, Py_LE);
1791 if (result != Py_NotImplemented) {
1792 Py_LeaveRecursiveCall();
1794 if (unlikely(result == NULL)) {
1795 return NUITKA_BOOL_EXCEPTION;
1799 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1805 Py_DECREF_IMMORTAL(result);
1809 cmpfunc fcmp = NULL;
1812 int c = (*fcmp)(operand1, operand2);
1813 c = adjust_tp_compare(c);
1815 Py_LeaveRecursiveCall();
1818 return NUITKA_BOOL_EXCEPTION;
1841 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1845 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1854 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1855 f = TP_RICHCOMPARE(type2);
1858 PyObject *result = (*f)(operand2, operand1, Py_GE);
1860 if (result != Py_NotImplemented) {
1861 Py_LeaveRecursiveCall();
1863 if (unlikely(result == NULL)) {
1864 return NUITKA_BOOL_EXCEPTION;
1868 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1874 Py_DECREF_IMMORTAL(result);
1878 f = PyString_Type.tp_richcompare;
1880 PyObject *result = (*f)(operand1, operand2, Py_LE);
1882 if (result != Py_NotImplemented) {
1883 Py_LeaveRecursiveCall();
1885 if (unlikely(result == NULL)) {
1886 return NUITKA_BOOL_EXCEPTION;
1890 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1896 Py_DECREF_IMMORTAL(result);
1899 f = TP_RICHCOMPARE(type2);
1901 PyObject *result = (*f)(operand2, operand1, Py_GE);
1903 if (result != Py_NotImplemented) {
1904 Py_LeaveRecursiveCall();
1906 if (unlikely(result == NULL)) {
1907 return NUITKA_BOOL_EXCEPTION;
1911 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1917 Py_DECREF_IMMORTAL(result);
1923 cmpfunc fcmp = NULL;
1924 c = (*fcmp)(operand1, operand2);
1925 }
else if (PyInstance_Check(operand2)) {
1926 cmpfunc fcmp = type2->tp_compare;
1927 c = (*fcmp)(operand1, operand2);
1929 c = try_3way_compare(operand1, operand2);
1933 if (&PyString_Type == type2) {
1934 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1935 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1937 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1938 }
else if (operand1 == Py_None) {
1941 }
else if (operand2 == Py_None) {
1944 }
else if (PyNumber_Check(operand1)) {
1947 if (PyNumber_Check(operand2)) {
1949 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1950 Py_uintptr_t bb = (Py_uintptr_t)type2;
1952 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1956 }
else if (PyNumber_Check(operand2)) {
1960 int s = strcmp(
"str", type2->tp_name);
1968 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1969 Py_uintptr_t bb = (Py_uintptr_t)type2;
1971 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1976 Py_LeaveRecursiveCall();
1978 if (unlikely(c <= -2)) {
1979 return NUITKA_BOOL_EXCEPTION;
2004 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2008 bool checked_reverse_op =
false;
2011 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
2012 f = TP_RICHCOMPARE(type2);
2015 checked_reverse_op =
true;
2017 PyObject *result = (*f)(operand2, operand1, Py_GE);
2019 if (result != Py_NotImplemented) {
2020 Py_LeaveRecursiveCall();
2022 if (unlikely(result == NULL)) {
2023 return NUITKA_BOOL_EXCEPTION;
2027 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2033 Py_DECREF_IMMORTAL(result);
2037 f = PyString_Type.tp_richcompare;
2040 PyObject *result = (*f)(operand1, operand2, Py_LE);
2042 if (result != Py_NotImplemented) {
2043 Py_LeaveRecursiveCall();
2045 if (unlikely(result == NULL)) {
2046 return NUITKA_BOOL_EXCEPTION;
2050 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2056 Py_DECREF_IMMORTAL(result);
2059 if (checked_reverse_op ==
false) {
2060 f = TP_RICHCOMPARE(type2);
2063 PyObject *result = (*f)(operand2, operand1, Py_GE);
2065 if (result != Py_NotImplemented) {
2066 Py_LeaveRecursiveCall();
2068 if (unlikely(result == NULL)) {
2069 return NUITKA_BOOL_EXCEPTION;
2073 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2079 Py_DECREF_IMMORTAL(result);
2083 Py_LeaveRecursiveCall();
2089 bool r = operand1 == operand2;
2090 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2095 bool r = operand1 != operand2;
2096 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2101#if PYTHON_VERSION < 0x360
2102 PyErr_Format(PyExc_TypeError,
"unorderable types: str() <= %s()", type2->tp_name);
2104 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'str' and '%s'", type2->tp_name);
2106 return NUITKA_BOOL_EXCEPTION;
2112static PyObject *COMPARE_LE_OBJECT_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2113 CHECK_OBJECT(operand1);
2114 assert(PyUnicode_CheckExact(operand1));
2115 CHECK_OBJECT(operand2);
2116 assert(PyUnicode_CheckExact(operand2));
2118 PyUnicodeObject *a = (PyUnicodeObject *)operand1;
2119 PyUnicodeObject *b = (PyUnicodeObject *)operand2;
2122 if (operand1 == operand2) {
2126 PyObject *result = BOOL_FROM(r);
2127 Py_INCREF_IMMORTAL(result);
2131 PyObject *r = PyUnicode_RichCompare((PyObject *)a, (PyObject *)b, Py_LE);
2137PyObject *RICH_COMPARE_LE_OBJECT_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
2139 if (Py_TYPE(operand1) == &PyUnicode_Type) {
2140 return COMPARE_LE_OBJECT_UNICODE_UNICODE(operand1, operand2);
2143#if PYTHON_VERSION < 0x300
2144 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2148 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2153 PyTypeObject *type1 = Py_TYPE(operand1);
2155#if PYTHON_VERSION < 0x300
2157 if (type1 == &PyUnicode_Type && !0) {
2159 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2161 if (frich != NULL) {
2162 PyObject *result = (*frich)(operand1, operand2, Py_LE);
2164 if (result != Py_NotImplemented) {
2165 Py_LeaveRecursiveCall();
2170 Py_DECREF_IMMORTAL(result);
2174 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2177 int c = (*fcmp)(operand1, operand2);
2178 c = adjust_tp_compare(c);
2180 Py_LeaveRecursiveCall();
2206 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2210 PyObject *result = BOOL_FROM(r);
2211 Py_INCREF_IMMORTAL(result);
2219 if (type1 != &PyUnicode_Type && 0) {
2220 f = PyUnicode_Type.tp_richcompare;
2223 PyObject *result = (*f)(operand2, operand1, Py_GE);
2225 if (result != Py_NotImplemented) {
2226 Py_LeaveRecursiveCall();
2231 Py_DECREF_IMMORTAL(result);
2235 f = TP_RICHCOMPARE(type1);
2237 PyObject *result = (*f)(operand1, operand2, Py_LE);
2239 if (result != Py_NotImplemented) {
2240 Py_LeaveRecursiveCall();
2245 Py_DECREF_IMMORTAL(result);
2248 f = PyUnicode_Type.tp_richcompare;
2250 PyObject *result = (*f)(operand2, operand1, Py_GE);
2252 if (result != Py_NotImplemented) {
2253 Py_LeaveRecursiveCall();
2258 Py_DECREF_IMMORTAL(result);
2263 if (PyInstance_Check(operand1)) {
2264 cmpfunc fcmp = type1->tp_compare;
2265 c = (*fcmp)(operand1, operand2);
2267 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2268 c = (*fcmp)(operand1, operand2);
2270 c = try_3way_compare(operand1, operand2);
2274 if (type1 == &PyUnicode_Type) {
2275 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2276 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2278 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2279 }
else if (operand1 == Py_None) {
2282 }
else if (operand2 == Py_None) {
2285 }
else if (PyNumber_Check(operand1)) {
2288 if (PyNumber_Check(operand2)) {
2290 Py_uintptr_t aa = (Py_uintptr_t)type1;
2291 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2293 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2297 }
else if (PyNumber_Check(operand2)) {
2301 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"unicode" :
"str"));
2309 Py_uintptr_t aa = (Py_uintptr_t)type1;
2310 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2312 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2317 Py_LeaveRecursiveCall();
2319 if (unlikely(c <= -2)) {
2345 PyObject *result = BOOL_FROM(r);
2346 Py_INCREF_IMMORTAL(result);
2349 bool checked_reverse_op =
false;
2352 if (type1 != &PyUnicode_Type && Nuitka_Type_IsSubtype(&PyUnicode_Type, type1)) {
2353 f = PyUnicode_Type.tp_richcompare;
2356 checked_reverse_op =
true;
2358 PyObject *result = (*f)(operand2, operand1, Py_GE);
2360 if (result != Py_NotImplemented) {
2361 Py_LeaveRecursiveCall();
2366 Py_DECREF_IMMORTAL(result);
2370 f = TP_RICHCOMPARE(type1);
2373 PyObject *result = (*f)(operand1, operand2, Py_LE);
2375 if (result != Py_NotImplemented) {
2376 Py_LeaveRecursiveCall();
2381 Py_DECREF_IMMORTAL(result);
2384 if (checked_reverse_op ==
false) {
2385 f = PyUnicode_Type.tp_richcompare;
2388 PyObject *result = (*f)(operand2, operand1, Py_GE);
2390 if (result != Py_NotImplemented) {
2391 Py_LeaveRecursiveCall();
2396 Py_DECREF_IMMORTAL(result);
2400 Py_LeaveRecursiveCall();
2406 bool r = operand1 == operand2;
2407 PyObject *result = BOOL_FROM(r);
2408 Py_INCREF_IMMORTAL(result);
2412 bool r = operand1 != operand2;
2413 PyObject *result = BOOL_FROM(r);
2414 Py_INCREF_IMMORTAL(result);
2418#if PYTHON_VERSION < 0x300
2419 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= unicode()", type1->tp_name);
2420#elif PYTHON_VERSION < 0x360
2421 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= str()", type1->tp_name);
2423 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'str'", type1->tp_name);
2431PyObject *RICH_COMPARE_LE_OBJECT_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
2433 if (&PyUnicode_Type == Py_TYPE(operand2)) {
2434 return COMPARE_LE_OBJECT_UNICODE_UNICODE(operand1, operand2);
2437#if PYTHON_VERSION < 0x300
2438 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2442 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2447 PyTypeObject *type2 = Py_TYPE(operand2);
2449#if PYTHON_VERSION < 0x300
2451 if (&PyUnicode_Type == type2 && !0) {
2453 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2455 if (frich != NULL) {
2456 PyObject *result = (*frich)(operand1, operand2, Py_LE);
2458 if (result != Py_NotImplemented) {
2459 Py_LeaveRecursiveCall();
2464 Py_DECREF_IMMORTAL(result);
2468 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2471 int c = (*fcmp)(operand1, operand2);
2472 c = adjust_tp_compare(c);
2474 Py_LeaveRecursiveCall();
2500 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2504 PyObject *result = BOOL_FROM(r);
2505 Py_INCREF_IMMORTAL(result);
2513 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
2514 f = TP_RICHCOMPARE(type2);
2517 PyObject *result = (*f)(operand2, operand1, Py_GE);
2519 if (result != Py_NotImplemented) {
2520 Py_LeaveRecursiveCall();
2525 Py_DECREF_IMMORTAL(result);
2529 f = PyUnicode_Type.tp_richcompare;
2531 PyObject *result = (*f)(operand1, operand2, Py_LE);
2533 if (result != Py_NotImplemented) {
2534 Py_LeaveRecursiveCall();
2539 Py_DECREF_IMMORTAL(result);
2542 f = TP_RICHCOMPARE(type2);
2544 PyObject *result = (*f)(operand2, operand1, Py_GE);
2546 if (result != Py_NotImplemented) {
2547 Py_LeaveRecursiveCall();
2552 Py_DECREF_IMMORTAL(result);
2558 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2559 c = (*fcmp)(operand1, operand2);
2560 }
else if (PyInstance_Check(operand2)) {
2561 cmpfunc fcmp = type2->tp_compare;
2562 c = (*fcmp)(operand1, operand2);
2564 c = try_3way_compare(operand1, operand2);
2568 if (&PyUnicode_Type == type2) {
2569 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2570 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2572 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2573 }
else if (operand1 == Py_None) {
2576 }
else if (operand2 == Py_None) {
2579 }
else if (PyNumber_Check(operand1)) {
2582 if (PyNumber_Check(operand2)) {
2584 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
2585 Py_uintptr_t bb = (Py_uintptr_t)type2;
2587 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2591 }
else if (PyNumber_Check(operand2)) {
2595 int s = strcmp((PYTHON_VERSION < 0x300 ?
"unicode" :
"str"), type2->tp_name);
2603 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
2604 Py_uintptr_t bb = (Py_uintptr_t)type2;
2606 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2611 Py_LeaveRecursiveCall();
2613 if (unlikely(c <= -2)) {
2639 PyObject *result = BOOL_FROM(r);
2640 Py_INCREF_IMMORTAL(result);
2643 bool checked_reverse_op =
false;
2646 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
2647 f = TP_RICHCOMPARE(type2);
2650 checked_reverse_op =
true;
2652 PyObject *result = (*f)(operand2, operand1, Py_GE);
2654 if (result != Py_NotImplemented) {
2655 Py_LeaveRecursiveCall();
2660 Py_DECREF_IMMORTAL(result);
2664 f = PyUnicode_Type.tp_richcompare;
2667 PyObject *result = (*f)(operand1, operand2, Py_LE);
2669 if (result != Py_NotImplemented) {
2670 Py_LeaveRecursiveCall();
2675 Py_DECREF_IMMORTAL(result);
2678 if (checked_reverse_op ==
false) {
2679 f = TP_RICHCOMPARE(type2);
2682 PyObject *result = (*f)(operand2, operand1, Py_GE);
2684 if (result != Py_NotImplemented) {
2685 Py_LeaveRecursiveCall();
2690 Py_DECREF_IMMORTAL(result);
2694 Py_LeaveRecursiveCall();
2700 bool r = operand1 == operand2;
2701 PyObject *result = BOOL_FROM(r);
2702 Py_INCREF_IMMORTAL(result);
2706 bool r = operand1 != operand2;
2707 PyObject *result = BOOL_FROM(r);
2708 Py_INCREF_IMMORTAL(result);
2712#if PYTHON_VERSION < 0x300
2713 PyErr_Format(PyExc_TypeError,
"unorderable types: unicode() <= %s()", type2->tp_name);
2714#elif PYTHON_VERSION < 0x360
2715 PyErr_Format(PyExc_TypeError,
"unorderable types: str() <= %s()", type2->tp_name);
2717 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'str' and '%s'", type2->tp_name);
2726PyObject *RICH_COMPARE_LE_OBJECT_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2728 return COMPARE_LE_OBJECT_UNICODE_UNICODE(operand1, operand2);
2731static bool COMPARE_LE_CBOOL_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2732 CHECK_OBJECT(operand1);
2733 assert(PyUnicode_CheckExact(operand1));
2734 CHECK_OBJECT(operand2);
2735 assert(PyUnicode_CheckExact(operand2));
2737 PyUnicodeObject *a = (PyUnicodeObject *)operand1;
2738 PyUnicodeObject *b = (PyUnicodeObject *)operand2;
2741 if (operand1 == operand2) {
2750 PyObject *r = PyUnicode_RichCompare((PyObject *)a, (PyObject *)b, Py_LE);
2754 bool result = r == Py_True;
2755 Py_DECREF_IMMORTAL(r);
2761bool RICH_COMPARE_LE_CBOOL_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2763 return COMPARE_LE_CBOOL_UNICODE_UNICODE(operand1, operand2);
2767nuitka_bool RICH_COMPARE_LE_NBOOL_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
2769 if (Py_TYPE(operand1) == &PyUnicode_Type) {
2770 return COMPARE_LE_CBOOL_UNICODE_UNICODE(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2773#if PYTHON_VERSION < 0x300
2774 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2775 return NUITKA_BOOL_EXCEPTION;
2778 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2779 return NUITKA_BOOL_EXCEPTION;
2783 PyTypeObject *type1 = Py_TYPE(operand1);
2785#if PYTHON_VERSION < 0x300
2787 if (type1 == &PyUnicode_Type && !0) {
2789 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2791 if (frich != NULL) {
2792 PyObject *result = (*frich)(operand1, operand2, Py_LE);
2794 if (result != Py_NotImplemented) {
2795 Py_LeaveRecursiveCall();
2797 if (unlikely(result == NULL)) {
2798 return NUITKA_BOOL_EXCEPTION;
2802 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2808 Py_DECREF_IMMORTAL(result);
2812 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2815 int c = (*fcmp)(operand1, operand2);
2816 c = adjust_tp_compare(c);
2818 Py_LeaveRecursiveCall();
2821 return NUITKA_BOOL_EXCEPTION;
2844 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2848 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2857 if (type1 != &PyUnicode_Type && 0) {
2858 f = PyUnicode_Type.tp_richcompare;
2861 PyObject *result = (*f)(operand2, operand1, Py_GE);
2863 if (result != Py_NotImplemented) {
2864 Py_LeaveRecursiveCall();
2866 if (unlikely(result == NULL)) {
2867 return NUITKA_BOOL_EXCEPTION;
2871 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2877 Py_DECREF_IMMORTAL(result);
2881 f = TP_RICHCOMPARE(type1);
2883 PyObject *result = (*f)(operand1, operand2, Py_LE);
2885 if (result != Py_NotImplemented) {
2886 Py_LeaveRecursiveCall();
2888 if (unlikely(result == NULL)) {
2889 return NUITKA_BOOL_EXCEPTION;
2893 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2899 Py_DECREF_IMMORTAL(result);
2902 f = PyUnicode_Type.tp_richcompare;
2904 PyObject *result = (*f)(operand2, operand1, Py_GE);
2906 if (result != Py_NotImplemented) {
2907 Py_LeaveRecursiveCall();
2909 if (unlikely(result == NULL)) {
2910 return NUITKA_BOOL_EXCEPTION;
2914 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2920 Py_DECREF_IMMORTAL(result);
2925 if (PyInstance_Check(operand1)) {
2926 cmpfunc fcmp = type1->tp_compare;
2927 c = (*fcmp)(operand1, operand2);
2929 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2930 c = (*fcmp)(operand1, operand2);
2932 c = try_3way_compare(operand1, operand2);
2936 if (type1 == &PyUnicode_Type) {
2937 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2938 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2940 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2941 }
else if (operand1 == Py_None) {
2944 }
else if (operand2 == Py_None) {
2947 }
else if (PyNumber_Check(operand1)) {
2950 if (PyNumber_Check(operand2)) {
2952 Py_uintptr_t aa = (Py_uintptr_t)type1;
2953 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2955 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2959 }
else if (PyNumber_Check(operand2)) {
2963 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"unicode" :
"str"));
2971 Py_uintptr_t aa = (Py_uintptr_t)type1;
2972 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2974 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2979 Py_LeaveRecursiveCall();
2981 if (unlikely(c <= -2)) {
2982 return NUITKA_BOOL_EXCEPTION;
3007 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3011 bool checked_reverse_op =
false;
3014 if (type1 != &PyUnicode_Type && Nuitka_Type_IsSubtype(&PyUnicode_Type, type1)) {
3015 f = PyUnicode_Type.tp_richcompare;
3018 checked_reverse_op =
true;
3020 PyObject *result = (*f)(operand2, operand1, Py_GE);
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 f = TP_RICHCOMPARE(type1);
3043 PyObject *result = (*f)(operand1, operand2, Py_LE);
3045 if (result != Py_NotImplemented) {
3046 Py_LeaveRecursiveCall();
3048 if (unlikely(result == NULL)) {
3049 return NUITKA_BOOL_EXCEPTION;
3053 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3059 Py_DECREF_IMMORTAL(result);
3062 if (checked_reverse_op ==
false) {
3063 f = PyUnicode_Type.tp_richcompare;
3066 PyObject *result = (*f)(operand2, operand1, Py_GE);
3068 if (result != Py_NotImplemented) {
3069 Py_LeaveRecursiveCall();
3071 if (unlikely(result == NULL)) {
3072 return NUITKA_BOOL_EXCEPTION;
3076 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3082 Py_DECREF_IMMORTAL(result);
3086 Py_LeaveRecursiveCall();
3092 bool r = operand1 == operand2;
3093 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3098 bool r = operand1 != operand2;
3099 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3104#if PYTHON_VERSION < 0x300
3105 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= unicode()", type1->tp_name);
3106#elif PYTHON_VERSION < 0x360
3107 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= str()", type1->tp_name);
3109 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'str'", type1->tp_name);
3111 return NUITKA_BOOL_EXCEPTION;
3117nuitka_bool RICH_COMPARE_LE_NBOOL_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
3119 if (&PyUnicode_Type == Py_TYPE(operand2)) {
3120 return COMPARE_LE_CBOOL_UNICODE_UNICODE(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3123#if PYTHON_VERSION < 0x300
3124 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3125 return NUITKA_BOOL_EXCEPTION;
3128 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3129 return NUITKA_BOOL_EXCEPTION;
3133 PyTypeObject *type2 = Py_TYPE(operand2);
3135#if PYTHON_VERSION < 0x300
3137 if (&PyUnicode_Type == type2 && !0) {
3139 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
3141 if (frich != NULL) {
3142 PyObject *result = (*frich)(operand1, operand2, Py_LE);
3144 if (result != Py_NotImplemented) {
3145 Py_LeaveRecursiveCall();
3147 if (unlikely(result == NULL)) {
3148 return NUITKA_BOOL_EXCEPTION;
3152 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3158 Py_DECREF_IMMORTAL(result);
3162 cmpfunc fcmp = PyUnicode_Type.tp_compare;
3165 int c = (*fcmp)(operand1, operand2);
3166 c = adjust_tp_compare(c);
3168 Py_LeaveRecursiveCall();
3171 return NUITKA_BOOL_EXCEPTION;
3194 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3198 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3207 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
3208 f = TP_RICHCOMPARE(type2);
3211 PyObject *result = (*f)(operand2, operand1, Py_GE);
3213 if (result != Py_NotImplemented) {
3214 Py_LeaveRecursiveCall();
3216 if (unlikely(result == NULL)) {
3217 return NUITKA_BOOL_EXCEPTION;
3221 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3227 Py_DECREF_IMMORTAL(result);
3231 f = PyUnicode_Type.tp_richcompare;
3233 PyObject *result = (*f)(operand1, operand2, Py_LE);
3235 if (result != Py_NotImplemented) {
3236 Py_LeaveRecursiveCall();
3238 if (unlikely(result == NULL)) {
3239 return NUITKA_BOOL_EXCEPTION;
3243 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3249 Py_DECREF_IMMORTAL(result);
3252 f = TP_RICHCOMPARE(type2);
3254 PyObject *result = (*f)(operand2, operand1, Py_GE);
3256 if (result != Py_NotImplemented) {
3257 Py_LeaveRecursiveCall();
3259 if (unlikely(result == NULL)) {
3260 return NUITKA_BOOL_EXCEPTION;
3264 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3270 Py_DECREF_IMMORTAL(result);
3276 cmpfunc fcmp = PyUnicode_Type.tp_compare;
3277 c = (*fcmp)(operand1, operand2);
3278 }
else if (PyInstance_Check(operand2)) {
3279 cmpfunc fcmp = type2->tp_compare;
3280 c = (*fcmp)(operand1, operand2);
3282 c = try_3way_compare(operand1, operand2);
3286 if (&PyUnicode_Type == type2) {
3287 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3288 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3290 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3291 }
else if (operand1 == Py_None) {
3294 }
else if (operand2 == Py_None) {
3297 }
else if (PyNumber_Check(operand1)) {
3300 if (PyNumber_Check(operand2)) {
3302 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
3303 Py_uintptr_t bb = (Py_uintptr_t)type2;
3305 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3309 }
else if (PyNumber_Check(operand2)) {
3313 int s = strcmp((PYTHON_VERSION < 0x300 ?
"unicode" :
"str"), type2->tp_name);
3321 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
3322 Py_uintptr_t bb = (Py_uintptr_t)type2;
3324 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3329 Py_LeaveRecursiveCall();
3331 if (unlikely(c <= -2)) {
3332 return NUITKA_BOOL_EXCEPTION;
3357 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3361 bool checked_reverse_op =
false;
3364 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
3365 f = TP_RICHCOMPARE(type2);
3368 checked_reverse_op =
true;
3370 PyObject *result = (*f)(operand2, operand1, Py_GE);
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 f = PyUnicode_Type.tp_richcompare;
3393 PyObject *result = (*f)(operand1, operand2, Py_LE);
3395 if (result != Py_NotImplemented) {
3396 Py_LeaveRecursiveCall();
3398 if (unlikely(result == NULL)) {
3399 return NUITKA_BOOL_EXCEPTION;
3403 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3409 Py_DECREF_IMMORTAL(result);
3412 if (checked_reverse_op ==
false) {
3413 f = TP_RICHCOMPARE(type2);
3416 PyObject *result = (*f)(operand2, operand1, Py_GE);
3418 if (result != Py_NotImplemented) {
3419 Py_LeaveRecursiveCall();
3421 if (unlikely(result == NULL)) {
3422 return NUITKA_BOOL_EXCEPTION;
3426 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3432 Py_DECREF_IMMORTAL(result);
3436 Py_LeaveRecursiveCall();
3442 bool r = operand1 == operand2;
3443 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3448 bool r = operand1 != operand2;
3449 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3454#if PYTHON_VERSION < 0x300
3455 PyErr_Format(PyExc_TypeError,
"unorderable types: unicode() <= %s()", type2->tp_name);
3456#elif PYTHON_VERSION < 0x360
3457 PyErr_Format(PyExc_TypeError,
"unorderable types: str() <= %s()", type2->tp_name);
3459 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'str' and '%s'", type2->tp_name);
3461 return NUITKA_BOOL_EXCEPTION;
3466#if PYTHON_VERSION >= 0x300
3467static PyObject *COMPARE_LE_OBJECT_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
3468 CHECK_OBJECT(operand1);
3469 assert(PyBytes_CheckExact(operand1));
3470 CHECK_OBJECT(operand2);
3471 assert(PyBytes_CheckExact(operand2));
3473 PyBytesObject *a = (PyBytesObject *)operand1;
3474 PyBytesObject *b = (PyBytesObject *)operand2;
3477 if (operand1 == operand2) {
3481 PyObject *result = BOOL_FROM(r);
3482 Py_INCREF_IMMORTAL(result);
3486 Py_ssize_t len_a = Py_SIZE(operand1);
3487 Py_ssize_t len_b = Py_SIZE(operand2);
3489 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
3493 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
3496 c = memcmp(a->ob_sval, b->ob_sval, min_len);
3503 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
3509 PyObject *result = BOOL_FROM(c != 0);
3510 Py_INCREF_IMMORTAL(result);
3514#if PYTHON_VERSION >= 0x300
3516PyObject *RICH_COMPARE_LE_OBJECT_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
3518 if (Py_TYPE(operand1) == &PyBytes_Type) {
3519 return COMPARE_LE_OBJECT_BYTES_BYTES(operand1, operand2);
3522#if PYTHON_VERSION < 0x300
3523 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3527 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3532 PyTypeObject *type1 = Py_TYPE(operand1);
3534#if PYTHON_VERSION < 0x300
3536 if (type1 == &PyBytes_Type && !0) {
3538 richcmpfunc frich = PyBytes_Type.tp_richcompare;
3540 if (frich != NULL) {
3541 PyObject *result = (*frich)(operand1, operand2, Py_LE);
3543 if (result != Py_NotImplemented) {
3544 Py_LeaveRecursiveCall();
3549 Py_DECREF_IMMORTAL(result);
3553 cmpfunc fcmp = NULL;
3556 int c = (*fcmp)(operand1, operand2);
3557 c = adjust_tp_compare(c);
3559 Py_LeaveRecursiveCall();
3585 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3589 PyObject *result = BOOL_FROM(r);
3590 Py_INCREF_IMMORTAL(result);
3598 if (type1 != &PyBytes_Type && 0) {
3599 f = PyBytes_Type.tp_richcompare;
3602 PyObject *result = (*f)(operand2, operand1, Py_GE);
3604 if (result != Py_NotImplemented) {
3605 Py_LeaveRecursiveCall();
3610 Py_DECREF_IMMORTAL(result);
3614 f = TP_RICHCOMPARE(type1);
3616 PyObject *result = (*f)(operand1, operand2, Py_LE);
3618 if (result != Py_NotImplemented) {
3619 Py_LeaveRecursiveCall();
3624 Py_DECREF_IMMORTAL(result);
3627 f = PyBytes_Type.tp_richcompare;
3629 PyObject *result = (*f)(operand2, operand1, Py_GE);
3631 if (result != Py_NotImplemented) {
3632 Py_LeaveRecursiveCall();
3637 Py_DECREF_IMMORTAL(result);
3642 if (PyInstance_Check(operand1)) {
3643 cmpfunc fcmp = type1->tp_compare;
3644 c = (*fcmp)(operand1, operand2);
3646 cmpfunc fcmp = NULL;
3647 c = (*fcmp)(operand1, operand2);
3649 c = try_3way_compare(operand1, operand2);
3653 if (type1 == &PyBytes_Type) {
3654 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3655 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3657 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3658 }
else if (operand1 == Py_None) {
3661 }
else if (operand2 == Py_None) {
3664 }
else if (PyNumber_Check(operand1)) {
3667 if (PyNumber_Check(operand2)) {
3669 Py_uintptr_t aa = (Py_uintptr_t)type1;
3670 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
3672 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3676 }
else if (PyNumber_Check(operand2)) {
3680 int s = strcmp(type1->tp_name,
"bytes");
3688 Py_uintptr_t aa = (Py_uintptr_t)type1;
3689 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
3691 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3696 Py_LeaveRecursiveCall();
3698 if (unlikely(c <= -2)) {
3724 PyObject *result = BOOL_FROM(r);
3725 Py_INCREF_IMMORTAL(result);
3728 bool checked_reverse_op =
false;
3731 if (type1 != &PyBytes_Type && Nuitka_Type_IsSubtype(&PyBytes_Type, type1)) {
3732 f = PyBytes_Type.tp_richcompare;
3735 checked_reverse_op =
true;
3737 PyObject *result = (*f)(operand2, operand1, Py_GE);
3739 if (result != Py_NotImplemented) {
3740 Py_LeaveRecursiveCall();
3745 Py_DECREF_IMMORTAL(result);
3749 f = TP_RICHCOMPARE(type1);
3752 PyObject *result = (*f)(operand1, operand2, Py_LE);
3754 if (result != Py_NotImplemented) {
3755 Py_LeaveRecursiveCall();
3760 Py_DECREF_IMMORTAL(result);
3763 if (checked_reverse_op ==
false) {
3764 f = PyBytes_Type.tp_richcompare;
3767 PyObject *result = (*f)(operand2, operand1, Py_GE);
3769 if (result != Py_NotImplemented) {
3770 Py_LeaveRecursiveCall();
3775 Py_DECREF_IMMORTAL(result);
3779 Py_LeaveRecursiveCall();
3785 bool r = operand1 == operand2;
3786 PyObject *result = BOOL_FROM(r);
3787 Py_INCREF_IMMORTAL(result);
3791 bool r = operand1 != operand2;
3792 PyObject *result = BOOL_FROM(r);
3793 Py_INCREF_IMMORTAL(result);
3797#if PYTHON_VERSION < 0x360
3798 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= bytes()", type1->tp_name);
3800 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'bytes'", type1->tp_name);
3808#if PYTHON_VERSION >= 0x300
3810PyObject *RICH_COMPARE_LE_OBJECT_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
3812 if (&PyBytes_Type == Py_TYPE(operand2)) {
3813 return COMPARE_LE_OBJECT_BYTES_BYTES(operand1, operand2);
3816#if PYTHON_VERSION < 0x300
3817 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3821 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3826 PyTypeObject *type2 = Py_TYPE(operand2);
3828#if PYTHON_VERSION < 0x300
3830 if (&PyBytes_Type == type2 && !0) {
3832 richcmpfunc frich = PyBytes_Type.tp_richcompare;
3834 if (frich != NULL) {
3835 PyObject *result = (*frich)(operand1, operand2, Py_LE);
3837 if (result != Py_NotImplemented) {
3838 Py_LeaveRecursiveCall();
3843 Py_DECREF_IMMORTAL(result);
3847 cmpfunc fcmp = NULL;
3850 int c = (*fcmp)(operand1, operand2);
3851 c = adjust_tp_compare(c);
3853 Py_LeaveRecursiveCall();
3879 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3883 PyObject *result = BOOL_FROM(r);
3884 Py_INCREF_IMMORTAL(result);
3892 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
3893 f = TP_RICHCOMPARE(type2);
3896 PyObject *result = (*f)(operand2, operand1, Py_GE);
3898 if (result != Py_NotImplemented) {
3899 Py_LeaveRecursiveCall();
3904 Py_DECREF_IMMORTAL(result);
3908 f = PyBytes_Type.tp_richcompare;
3910 PyObject *result = (*f)(operand1, operand2, Py_LE);
3912 if (result != Py_NotImplemented) {
3913 Py_LeaveRecursiveCall();
3918 Py_DECREF_IMMORTAL(result);
3921 f = TP_RICHCOMPARE(type2);
3923 PyObject *result = (*f)(operand2, operand1, Py_GE);
3925 if (result != Py_NotImplemented) {
3926 Py_LeaveRecursiveCall();
3931 Py_DECREF_IMMORTAL(result);
3937 cmpfunc fcmp = NULL;
3938 c = (*fcmp)(operand1, operand2);
3939 }
else if (PyInstance_Check(operand2)) {
3940 cmpfunc fcmp = type2->tp_compare;
3941 c = (*fcmp)(operand1, operand2);
3943 c = try_3way_compare(operand1, operand2);
3947 if (&PyBytes_Type == type2) {
3948 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3949 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3951 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3952 }
else if (operand1 == Py_None) {
3955 }
else if (operand2 == Py_None) {
3958 }
else if (PyNumber_Check(operand1)) {
3961 if (PyNumber_Check(operand2)) {
3963 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
3964 Py_uintptr_t bb = (Py_uintptr_t)type2;
3966 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3970 }
else if (PyNumber_Check(operand2)) {
3974 int s = strcmp(
"bytes", type2->tp_name);
3982 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
3983 Py_uintptr_t bb = (Py_uintptr_t)type2;
3985 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3990 Py_LeaveRecursiveCall();
3992 if (unlikely(c <= -2)) {
4018 PyObject *result = BOOL_FROM(r);
4019 Py_INCREF_IMMORTAL(result);
4022 bool checked_reverse_op =
false;
4025 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4026 f = TP_RICHCOMPARE(type2);
4029 checked_reverse_op =
true;
4031 PyObject *result = (*f)(operand2, operand1, Py_GE);
4033 if (result != Py_NotImplemented) {
4034 Py_LeaveRecursiveCall();
4039 Py_DECREF_IMMORTAL(result);
4043 f = PyBytes_Type.tp_richcompare;
4046 PyObject *result = (*f)(operand1, operand2, Py_LE);
4048 if (result != Py_NotImplemented) {
4049 Py_LeaveRecursiveCall();
4054 Py_DECREF_IMMORTAL(result);
4057 if (checked_reverse_op ==
false) {
4058 f = TP_RICHCOMPARE(type2);
4061 PyObject *result = (*f)(operand2, operand1, Py_GE);
4063 if (result != Py_NotImplemented) {
4064 Py_LeaveRecursiveCall();
4069 Py_DECREF_IMMORTAL(result);
4073 Py_LeaveRecursiveCall();
4079 bool r = operand1 == operand2;
4080 PyObject *result = BOOL_FROM(r);
4081 Py_INCREF_IMMORTAL(result);
4085 bool r = operand1 != operand2;
4086 PyObject *result = BOOL_FROM(r);
4087 Py_INCREF_IMMORTAL(result);
4091#if PYTHON_VERSION < 0x360
4092 PyErr_Format(PyExc_TypeError,
"unorderable types: bytes() <= %s()", type2->tp_name);
4094 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'bytes' and '%s'", type2->tp_name);
4102#if PYTHON_VERSION >= 0x300
4104PyObject *RICH_COMPARE_LE_OBJECT_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4106 return COMPARE_LE_OBJECT_BYTES_BYTES(operand1, operand2);
4110#if PYTHON_VERSION >= 0x300
4111static bool COMPARE_LE_CBOOL_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4112 CHECK_OBJECT(operand1);
4113 assert(PyBytes_CheckExact(operand1));
4114 CHECK_OBJECT(operand2);
4115 assert(PyBytes_CheckExact(operand2));
4117 PyBytesObject *a = (PyBytesObject *)operand1;
4118 PyBytesObject *b = (PyBytesObject *)operand2;
4121 if (operand1 == operand2) {
4130 Py_ssize_t len_a = Py_SIZE(operand1);
4131 Py_ssize_t len_b = Py_SIZE(operand2);
4133 Py_ssize_t min_len = (len_a < len_b) ? len_a : len_b;
4137 c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
4140 c = memcmp(a->ob_sval, b->ob_sval, min_len);
4147 c = (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
4153 bool result = c != 0;
4158#if PYTHON_VERSION >= 0x300
4160bool RICH_COMPARE_LE_CBOOL_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4162 return COMPARE_LE_CBOOL_BYTES_BYTES(operand1, operand2);
4166#if PYTHON_VERSION >= 0x300
4168nuitka_bool RICH_COMPARE_LE_NBOOL_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
4170 if (Py_TYPE(operand1) == &PyBytes_Type) {
4171 return COMPARE_LE_CBOOL_BYTES_BYTES(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4174#if PYTHON_VERSION < 0x300
4175 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4176 return NUITKA_BOOL_EXCEPTION;
4179 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4180 return NUITKA_BOOL_EXCEPTION;
4184 PyTypeObject *type1 = Py_TYPE(operand1);
4186#if PYTHON_VERSION < 0x300
4188 if (type1 == &PyBytes_Type && !0) {
4190 richcmpfunc frich = PyBytes_Type.tp_richcompare;
4192 if (frich != NULL) {
4193 PyObject *result = (*frich)(operand1, operand2, Py_LE);
4195 if (result != Py_NotImplemented) {
4196 Py_LeaveRecursiveCall();
4198 if (unlikely(result == NULL)) {
4199 return NUITKA_BOOL_EXCEPTION;
4203 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4209 Py_DECREF_IMMORTAL(result);
4213 cmpfunc fcmp = NULL;
4216 int c = (*fcmp)(operand1, operand2);
4217 c = adjust_tp_compare(c);
4219 Py_LeaveRecursiveCall();
4222 return NUITKA_BOOL_EXCEPTION;
4245 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4249 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4258 if (type1 != &PyBytes_Type && 0) {
4259 f = PyBytes_Type.tp_richcompare;
4262 PyObject *result = (*f)(operand2, operand1, Py_GE);
4264 if (result != Py_NotImplemented) {
4265 Py_LeaveRecursiveCall();
4267 if (unlikely(result == NULL)) {
4268 return NUITKA_BOOL_EXCEPTION;
4272 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4278 Py_DECREF_IMMORTAL(result);
4282 f = TP_RICHCOMPARE(type1);
4284 PyObject *result = (*f)(operand1, operand2, Py_LE);
4286 if (result != Py_NotImplemented) {
4287 Py_LeaveRecursiveCall();
4289 if (unlikely(result == NULL)) {
4290 return NUITKA_BOOL_EXCEPTION;
4294 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4300 Py_DECREF_IMMORTAL(result);
4303 f = PyBytes_Type.tp_richcompare;
4305 PyObject *result = (*f)(operand2, operand1, Py_GE);
4307 if (result != Py_NotImplemented) {
4308 Py_LeaveRecursiveCall();
4310 if (unlikely(result == NULL)) {
4311 return NUITKA_BOOL_EXCEPTION;
4315 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4321 Py_DECREF_IMMORTAL(result);
4326 if (PyInstance_Check(operand1)) {
4327 cmpfunc fcmp = type1->tp_compare;
4328 c = (*fcmp)(operand1, operand2);
4330 cmpfunc fcmp = NULL;
4331 c = (*fcmp)(operand1, operand2);
4333 c = try_3way_compare(operand1, operand2);
4337 if (type1 == &PyBytes_Type) {
4338 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4339 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4341 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4342 }
else if (operand1 == Py_None) {
4345 }
else if (operand2 == Py_None) {
4348 }
else if (PyNumber_Check(operand1)) {
4351 if (PyNumber_Check(operand2)) {
4353 Py_uintptr_t aa = (Py_uintptr_t)type1;
4354 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
4356 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4360 }
else if (PyNumber_Check(operand2)) {
4364 int s = strcmp(type1->tp_name,
"bytes");
4372 Py_uintptr_t aa = (Py_uintptr_t)type1;
4373 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
4375 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4380 Py_LeaveRecursiveCall();
4382 if (unlikely(c <= -2)) {
4383 return NUITKA_BOOL_EXCEPTION;
4408 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4412 bool checked_reverse_op =
false;
4415 if (type1 != &PyBytes_Type && Nuitka_Type_IsSubtype(&PyBytes_Type, type1)) {
4416 f = PyBytes_Type.tp_richcompare;
4419 checked_reverse_op =
true;
4421 PyObject *result = (*f)(operand2, operand1, Py_GE);
4423 if (result != Py_NotImplemented) {
4424 Py_LeaveRecursiveCall();
4426 if (unlikely(result == NULL)) {
4427 return NUITKA_BOOL_EXCEPTION;
4431 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4437 Py_DECREF_IMMORTAL(result);
4441 f = TP_RICHCOMPARE(type1);
4444 PyObject *result = (*f)(operand1, operand2, Py_LE);
4446 if (result != Py_NotImplemented) {
4447 Py_LeaveRecursiveCall();
4449 if (unlikely(result == NULL)) {
4450 return NUITKA_BOOL_EXCEPTION;
4454 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4460 Py_DECREF_IMMORTAL(result);
4463 if (checked_reverse_op ==
false) {
4464 f = PyBytes_Type.tp_richcompare;
4467 PyObject *result = (*f)(operand2, operand1, Py_GE);
4469 if (result != Py_NotImplemented) {
4470 Py_LeaveRecursiveCall();
4472 if (unlikely(result == NULL)) {
4473 return NUITKA_BOOL_EXCEPTION;
4477 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4483 Py_DECREF_IMMORTAL(result);
4487 Py_LeaveRecursiveCall();
4493 bool r = operand1 == operand2;
4494 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4499 bool r = operand1 != operand2;
4500 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4505#if PYTHON_VERSION < 0x360
4506 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= bytes()", type1->tp_name);
4508 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'bytes'", type1->tp_name);
4510 return NUITKA_BOOL_EXCEPTION;
4516#if PYTHON_VERSION >= 0x300
4518nuitka_bool RICH_COMPARE_LE_NBOOL_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
4520 if (&PyBytes_Type == Py_TYPE(operand2)) {
4521 return COMPARE_LE_CBOOL_BYTES_BYTES(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4524#if PYTHON_VERSION < 0x300
4525 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4526 return NUITKA_BOOL_EXCEPTION;
4529 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4530 return NUITKA_BOOL_EXCEPTION;
4534 PyTypeObject *type2 = Py_TYPE(operand2);
4536#if PYTHON_VERSION < 0x300
4538 if (&PyBytes_Type == type2 && !0) {
4540 richcmpfunc frich = PyBytes_Type.tp_richcompare;
4542 if (frich != NULL) {
4543 PyObject *result = (*frich)(operand1, operand2, Py_LE);
4545 if (result != Py_NotImplemented) {
4546 Py_LeaveRecursiveCall();
4548 if (unlikely(result == NULL)) {
4549 return NUITKA_BOOL_EXCEPTION;
4553 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4559 Py_DECREF_IMMORTAL(result);
4563 cmpfunc fcmp = NULL;
4566 int c = (*fcmp)(operand1, operand2);
4567 c = adjust_tp_compare(c);
4569 Py_LeaveRecursiveCall();
4572 return NUITKA_BOOL_EXCEPTION;
4595 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4599 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4608 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4609 f = TP_RICHCOMPARE(type2);
4612 PyObject *result = (*f)(operand2, operand1, Py_GE);
4614 if (result != Py_NotImplemented) {
4615 Py_LeaveRecursiveCall();
4617 if (unlikely(result == NULL)) {
4618 return NUITKA_BOOL_EXCEPTION;
4622 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4628 Py_DECREF_IMMORTAL(result);
4632 f = PyBytes_Type.tp_richcompare;
4634 PyObject *result = (*f)(operand1, operand2, Py_LE);
4636 if (result != Py_NotImplemented) {
4637 Py_LeaveRecursiveCall();
4639 if (unlikely(result == NULL)) {
4640 return NUITKA_BOOL_EXCEPTION;
4644 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4650 Py_DECREF_IMMORTAL(result);
4653 f = TP_RICHCOMPARE(type2);
4655 PyObject *result = (*f)(operand2, operand1, Py_GE);
4657 if (result != Py_NotImplemented) {
4658 Py_LeaveRecursiveCall();
4660 if (unlikely(result == NULL)) {
4661 return NUITKA_BOOL_EXCEPTION;
4665 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4671 Py_DECREF_IMMORTAL(result);
4677 cmpfunc fcmp = NULL;
4678 c = (*fcmp)(operand1, operand2);
4679 }
else if (PyInstance_Check(operand2)) {
4680 cmpfunc fcmp = type2->tp_compare;
4681 c = (*fcmp)(operand1, operand2);
4683 c = try_3way_compare(operand1, operand2);
4687 if (&PyBytes_Type == type2) {
4688 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4689 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4691 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4692 }
else if (operand1 == Py_None) {
4695 }
else if (operand2 == Py_None) {
4698 }
else if (PyNumber_Check(operand1)) {
4701 if (PyNumber_Check(operand2)) {
4703 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4704 Py_uintptr_t bb = (Py_uintptr_t)type2;
4706 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4710 }
else if (PyNumber_Check(operand2)) {
4714 int s = strcmp(
"bytes", type2->tp_name);
4722 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4723 Py_uintptr_t bb = (Py_uintptr_t)type2;
4725 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4730 Py_LeaveRecursiveCall();
4732 if (unlikely(c <= -2)) {
4733 return NUITKA_BOOL_EXCEPTION;
4758 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4762 bool checked_reverse_op =
false;
4765 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4766 f = TP_RICHCOMPARE(type2);
4769 checked_reverse_op =
true;
4771 PyObject *result = (*f)(operand2, operand1, Py_GE);
4773 if (result != Py_NotImplemented) {
4774 Py_LeaveRecursiveCall();
4776 if (unlikely(result == NULL)) {
4777 return NUITKA_BOOL_EXCEPTION;
4781 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4787 Py_DECREF_IMMORTAL(result);
4791 f = PyBytes_Type.tp_richcompare;
4794 PyObject *result = (*f)(operand1, operand2, Py_LE);
4796 if (result != Py_NotImplemented) {
4797 Py_LeaveRecursiveCall();
4799 if (unlikely(result == NULL)) {
4800 return NUITKA_BOOL_EXCEPTION;
4804 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4810 Py_DECREF_IMMORTAL(result);
4813 if (checked_reverse_op ==
false) {
4814 f = TP_RICHCOMPARE(type2);
4817 PyObject *result = (*f)(operand2, operand1, Py_GE);
4819 if (result != Py_NotImplemented) {
4820 Py_LeaveRecursiveCall();
4822 if (unlikely(result == NULL)) {
4823 return NUITKA_BOOL_EXCEPTION;
4827 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4833 Py_DECREF_IMMORTAL(result);
4837 Py_LeaveRecursiveCall();
4843 bool r = operand1 == operand2;
4844 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4849 bool r = operand1 != operand2;
4850 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4855#if PYTHON_VERSION < 0x360
4856 PyErr_Format(PyExc_TypeError,
"unorderable types: bytes() <= %s()", type2->tp_name);
4858 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'bytes' and '%s'", type2->tp_name);
4860 return NUITKA_BOOL_EXCEPTION;
4866#if PYTHON_VERSION < 0x300
4868PyObject *RICH_COMPARE_LE_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
4870 if (Py_TYPE(operand1) == &PyInt_Type) {
4871 return COMPARE_LE_OBJECT_INT_INT(operand1, operand2);
4874#if PYTHON_VERSION < 0x300
4875 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4879 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4884 PyTypeObject *type1 = Py_TYPE(operand1);
4886#if PYTHON_VERSION < 0x300
4888 if (type1 == &PyInt_Type && !0) {
4890 richcmpfunc frich = NULL;
4892 if (frich != NULL) {
4893 PyObject *result = (*frich)(operand1, operand2, Py_LE);
4895 if (result != Py_NotImplemented) {
4896 Py_LeaveRecursiveCall();
4901 Py_DECREF_IMMORTAL(result);
4905 cmpfunc fcmp = PyInt_Type.tp_compare;
4908 int c = (*fcmp)(operand1, operand2);
4909 c = adjust_tp_compare(c);
4911 Py_LeaveRecursiveCall();
4937 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4941 PyObject *result = BOOL_FROM(r);
4942 Py_INCREF_IMMORTAL(result);
4950 if (type1 != &PyInt_Type && 0) {
4954 PyObject *result = (*f)(operand2, operand1, Py_GE);
4956 if (result != Py_NotImplemented) {
4957 Py_LeaveRecursiveCall();
4962 Py_DECREF_IMMORTAL(result);
4966 f = TP_RICHCOMPARE(type1);
4968 PyObject *result = (*f)(operand1, operand2, Py_LE);
4970 if (result != Py_NotImplemented) {
4971 Py_LeaveRecursiveCall();
4976 Py_DECREF_IMMORTAL(result);
4981 PyObject *result = (*f)(operand2, operand1, Py_GE);
4983 if (result != Py_NotImplemented) {
4984 Py_LeaveRecursiveCall();
4989 Py_DECREF_IMMORTAL(result);
4994 if (PyInstance_Check(operand1)) {
4995 cmpfunc fcmp = type1->tp_compare;
4996 c = (*fcmp)(operand1, operand2);
4998 cmpfunc fcmp = PyInt_Type.tp_compare;
4999 c = (*fcmp)(operand1, operand2);
5001 c = try_3way_compare(operand1, operand2);
5005 if (type1 == &PyInt_Type) {
5006 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5007 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5009 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5010 }
else if (operand1 == Py_None) {
5013 }
else if (operand2 == Py_None) {
5016 }
else if (PyNumber_Check(operand1)) {
5019 if (PyNumber_Check(operand2)) {
5021 Py_uintptr_t aa = (Py_uintptr_t)type1;
5022 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5024 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5028 }
else if (PyNumber_Check(operand2)) {
5032 int s = strcmp(type1->tp_name,
"int");
5040 Py_uintptr_t aa = (Py_uintptr_t)type1;
5041 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5043 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5048 Py_LeaveRecursiveCall();
5050 if (unlikely(c <= -2)) {
5076 PyObject *result = BOOL_FROM(r);
5077 Py_INCREF_IMMORTAL(result);
5080 bool checked_reverse_op =
false;
5083 if (type1 != &PyInt_Type && Nuitka_Type_IsSubtype(&PyInt_Type, type1)) {
5087 checked_reverse_op =
true;
5089 PyObject *result = (*f)(operand2, operand1, Py_GE);
5091 if (result != Py_NotImplemented) {
5092 Py_LeaveRecursiveCall();
5097 Py_DECREF_IMMORTAL(result);
5101 f = TP_RICHCOMPARE(type1);
5104 PyObject *result = (*f)(operand1, operand2, Py_LE);
5106 if (result != Py_NotImplemented) {
5107 Py_LeaveRecursiveCall();
5112 Py_DECREF_IMMORTAL(result);
5115 if (checked_reverse_op ==
false) {
5119 PyObject *result = (*f)(operand2, operand1, Py_GE);
5121 if (result != Py_NotImplemented) {
5122 Py_LeaveRecursiveCall();
5127 Py_DECREF_IMMORTAL(result);
5131 Py_LeaveRecursiveCall();
5137 bool r = operand1 == operand2;
5138 PyObject *result = BOOL_FROM(r);
5139 Py_INCREF_IMMORTAL(result);
5143 bool r = operand1 != operand2;
5144 PyObject *result = BOOL_FROM(r);
5145 Py_INCREF_IMMORTAL(result);
5149#if PYTHON_VERSION < 0x360
5150 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= int()", type1->tp_name);
5152 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'int'", type1->tp_name);
5160#if PYTHON_VERSION < 0x300
5162PyObject *RICH_COMPARE_LE_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
5164 if (&PyInt_Type == Py_TYPE(operand2)) {
5165 return COMPARE_LE_OBJECT_INT_INT(operand1, operand2);
5168#if PYTHON_VERSION < 0x300
5169 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5173 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5178 PyTypeObject *type2 = Py_TYPE(operand2);
5180#if PYTHON_VERSION < 0x300
5182 if (&PyInt_Type == type2 && !0) {
5184 richcmpfunc frich = NULL;
5186 if (frich != NULL) {
5187 PyObject *result = (*frich)(operand1, operand2, Py_LE);
5189 if (result != Py_NotImplemented) {
5190 Py_LeaveRecursiveCall();
5195 Py_DECREF_IMMORTAL(result);
5199 cmpfunc fcmp = PyInt_Type.tp_compare;
5202 int c = (*fcmp)(operand1, operand2);
5203 c = adjust_tp_compare(c);
5205 Py_LeaveRecursiveCall();
5231 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5235 PyObject *result = BOOL_FROM(r);
5236 Py_INCREF_IMMORTAL(result);
5244 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5245 f = TP_RICHCOMPARE(type2);
5248 PyObject *result = (*f)(operand2, operand1, Py_GE);
5250 if (result != Py_NotImplemented) {
5251 Py_LeaveRecursiveCall();
5256 Py_DECREF_IMMORTAL(result);
5262 PyObject *result = (*f)(operand1, operand2, Py_LE);
5264 if (result != Py_NotImplemented) {
5265 Py_LeaveRecursiveCall();
5270 Py_DECREF_IMMORTAL(result);
5273 f = TP_RICHCOMPARE(type2);
5275 PyObject *result = (*f)(operand2, operand1, Py_GE);
5277 if (result != Py_NotImplemented) {
5278 Py_LeaveRecursiveCall();
5283 Py_DECREF_IMMORTAL(result);
5289 cmpfunc fcmp = PyInt_Type.tp_compare;
5290 c = (*fcmp)(operand1, operand2);
5291 }
else if (PyInstance_Check(operand2)) {
5292 cmpfunc fcmp = type2->tp_compare;
5293 c = (*fcmp)(operand1, operand2);
5295 c = try_3way_compare(operand1, operand2);
5299 if (&PyInt_Type == type2) {
5300 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5301 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5303 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5304 }
else if (operand1 == Py_None) {
5307 }
else if (operand2 == Py_None) {
5310 }
else if (PyNumber_Check(operand1)) {
5313 if (PyNumber_Check(operand2)) {
5315 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5316 Py_uintptr_t bb = (Py_uintptr_t)type2;
5318 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5322 }
else if (PyNumber_Check(operand2)) {
5326 int s = strcmp(
"int", type2->tp_name);
5334 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5335 Py_uintptr_t bb = (Py_uintptr_t)type2;
5337 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5342 Py_LeaveRecursiveCall();
5344 if (unlikely(c <= -2)) {
5370 PyObject *result = BOOL_FROM(r);
5371 Py_INCREF_IMMORTAL(result);
5374 bool checked_reverse_op =
false;
5377 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5378 f = TP_RICHCOMPARE(type2);
5381 checked_reverse_op =
true;
5383 PyObject *result = (*f)(operand2, operand1, Py_GE);
5385 if (result != Py_NotImplemented) {
5386 Py_LeaveRecursiveCall();
5391 Py_DECREF_IMMORTAL(result);
5398 PyObject *result = (*f)(operand1, operand2, Py_LE);
5400 if (result != Py_NotImplemented) {
5401 Py_LeaveRecursiveCall();
5406 Py_DECREF_IMMORTAL(result);
5409 if (checked_reverse_op ==
false) {
5410 f = TP_RICHCOMPARE(type2);
5413 PyObject *result = (*f)(operand2, operand1, Py_GE);
5415 if (result != Py_NotImplemented) {
5416 Py_LeaveRecursiveCall();
5421 Py_DECREF_IMMORTAL(result);
5425 Py_LeaveRecursiveCall();
5431 bool r = operand1 == operand2;
5432 PyObject *result = BOOL_FROM(r);
5433 Py_INCREF_IMMORTAL(result);
5437 bool r = operand1 != operand2;
5438 PyObject *result = BOOL_FROM(r);
5439 Py_INCREF_IMMORTAL(result);
5443#if PYTHON_VERSION < 0x360
5444 PyErr_Format(PyExc_TypeError,
"unorderable types: int() <= %s()", type2->tp_name);
5446 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'int' and '%s'", type2->tp_name);
5454#if PYTHON_VERSION < 0x300
5456PyObject *RICH_COMPARE_LE_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
5458 return COMPARE_LE_OBJECT_INT_INT(operand1, operand2);
5462#if PYTHON_VERSION < 0x300
5464bool RICH_COMPARE_LE_CBOOL_INT_INT(PyObject *operand1, PyObject *operand2) {
5466 return COMPARE_LE_CBOOL_INT_INT(operand1, operand2);
5470#if PYTHON_VERSION < 0x300
5472nuitka_bool RICH_COMPARE_LE_NBOOL_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
5474 if (Py_TYPE(operand1) == &PyInt_Type) {
5475 return COMPARE_LE_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5478#if PYTHON_VERSION < 0x300
5479 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5480 return NUITKA_BOOL_EXCEPTION;
5483 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5484 return NUITKA_BOOL_EXCEPTION;
5488 PyTypeObject *type1 = Py_TYPE(operand1);
5490#if PYTHON_VERSION < 0x300
5492 if (type1 == &PyInt_Type && !0) {
5494 richcmpfunc frich = NULL;
5496 if (frich != NULL) {
5497 PyObject *result = (*frich)(operand1, operand2, Py_LE);
5499 if (result != Py_NotImplemented) {
5500 Py_LeaveRecursiveCall();
5502 if (unlikely(result == NULL)) {
5503 return NUITKA_BOOL_EXCEPTION;
5507 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5513 Py_DECREF_IMMORTAL(result);
5517 cmpfunc fcmp = PyInt_Type.tp_compare;
5520 int c = (*fcmp)(operand1, operand2);
5521 c = adjust_tp_compare(c);
5523 Py_LeaveRecursiveCall();
5526 return NUITKA_BOOL_EXCEPTION;
5549 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5553 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5562 if (type1 != &PyInt_Type && 0) {
5566 PyObject *result = (*f)(operand2, operand1, Py_GE);
5568 if (result != Py_NotImplemented) {
5569 Py_LeaveRecursiveCall();
5571 if (unlikely(result == NULL)) {
5572 return NUITKA_BOOL_EXCEPTION;
5576 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5582 Py_DECREF_IMMORTAL(result);
5586 f = TP_RICHCOMPARE(type1);
5588 PyObject *result = (*f)(operand1, operand2, Py_LE);
5590 if (result != Py_NotImplemented) {
5591 Py_LeaveRecursiveCall();
5593 if (unlikely(result == NULL)) {
5594 return NUITKA_BOOL_EXCEPTION;
5598 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5604 Py_DECREF_IMMORTAL(result);
5609 PyObject *result = (*f)(operand2, operand1, Py_GE);
5611 if (result != Py_NotImplemented) {
5612 Py_LeaveRecursiveCall();
5614 if (unlikely(result == NULL)) {
5615 return NUITKA_BOOL_EXCEPTION;
5619 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5625 Py_DECREF_IMMORTAL(result);
5630 if (PyInstance_Check(operand1)) {
5631 cmpfunc fcmp = type1->tp_compare;
5632 c = (*fcmp)(operand1, operand2);
5634 cmpfunc fcmp = PyInt_Type.tp_compare;
5635 c = (*fcmp)(operand1, operand2);
5637 c = try_3way_compare(operand1, operand2);
5641 if (type1 == &PyInt_Type) {
5642 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5643 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5645 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5646 }
else if (operand1 == Py_None) {
5649 }
else if (operand2 == Py_None) {
5652 }
else if (PyNumber_Check(operand1)) {
5655 if (PyNumber_Check(operand2)) {
5657 Py_uintptr_t aa = (Py_uintptr_t)type1;
5658 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5660 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5664 }
else if (PyNumber_Check(operand2)) {
5668 int s = strcmp(type1->tp_name,
"int");
5676 Py_uintptr_t aa = (Py_uintptr_t)type1;
5677 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5679 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5684 Py_LeaveRecursiveCall();
5686 if (unlikely(c <= -2)) {
5687 return NUITKA_BOOL_EXCEPTION;
5712 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5716 bool checked_reverse_op =
false;
5719 if (type1 != &PyInt_Type && Nuitka_Type_IsSubtype(&PyInt_Type, type1)) {
5723 checked_reverse_op =
true;
5725 PyObject *result = (*f)(operand2, operand1, Py_GE);
5727 if (result != Py_NotImplemented) {
5728 Py_LeaveRecursiveCall();
5730 if (unlikely(result == NULL)) {
5731 return NUITKA_BOOL_EXCEPTION;
5735 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5741 Py_DECREF_IMMORTAL(result);
5745 f = TP_RICHCOMPARE(type1);
5748 PyObject *result = (*f)(operand1, operand2, Py_LE);
5750 if (result != Py_NotImplemented) {
5751 Py_LeaveRecursiveCall();
5753 if (unlikely(result == NULL)) {
5754 return NUITKA_BOOL_EXCEPTION;
5758 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5764 Py_DECREF_IMMORTAL(result);
5767 if (checked_reverse_op ==
false) {
5771 PyObject *result = (*f)(operand2, operand1, Py_GE);
5773 if (result != Py_NotImplemented) {
5774 Py_LeaveRecursiveCall();
5776 if (unlikely(result == NULL)) {
5777 return NUITKA_BOOL_EXCEPTION;
5781 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5787 Py_DECREF_IMMORTAL(result);
5791 Py_LeaveRecursiveCall();
5797 bool r = operand1 == operand2;
5798 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5803 bool r = operand1 != operand2;
5804 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5809#if PYTHON_VERSION < 0x360
5810 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= int()", type1->tp_name);
5812 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'int'", type1->tp_name);
5814 return NUITKA_BOOL_EXCEPTION;
5820#if PYTHON_VERSION < 0x300
5822nuitka_bool RICH_COMPARE_LE_NBOOL_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
5824 if (&PyInt_Type == Py_TYPE(operand2)) {
5825 return COMPARE_LE_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5828#if PYTHON_VERSION < 0x300
5829 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5830 return NUITKA_BOOL_EXCEPTION;
5833 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5834 return NUITKA_BOOL_EXCEPTION;
5838 PyTypeObject *type2 = Py_TYPE(operand2);
5840#if PYTHON_VERSION < 0x300
5842 if (&PyInt_Type == type2 && !0) {
5844 richcmpfunc frich = NULL;
5846 if (frich != NULL) {
5847 PyObject *result = (*frich)(operand1, operand2, Py_LE);
5849 if (result != Py_NotImplemented) {
5850 Py_LeaveRecursiveCall();
5852 if (unlikely(result == NULL)) {
5853 return NUITKA_BOOL_EXCEPTION;
5857 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5863 Py_DECREF_IMMORTAL(result);
5867 cmpfunc fcmp = PyInt_Type.tp_compare;
5870 int c = (*fcmp)(operand1, operand2);
5871 c = adjust_tp_compare(c);
5873 Py_LeaveRecursiveCall();
5876 return NUITKA_BOOL_EXCEPTION;
5899 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5903 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5912 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5913 f = TP_RICHCOMPARE(type2);
5916 PyObject *result = (*f)(operand2, operand1, Py_GE);
5918 if (result != Py_NotImplemented) {
5919 Py_LeaveRecursiveCall();
5921 if (unlikely(result == NULL)) {
5922 return NUITKA_BOOL_EXCEPTION;
5926 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5932 Py_DECREF_IMMORTAL(result);
5938 PyObject *result = (*f)(operand1, operand2, Py_LE);
5940 if (result != Py_NotImplemented) {
5941 Py_LeaveRecursiveCall();
5943 if (unlikely(result == NULL)) {
5944 return NUITKA_BOOL_EXCEPTION;
5948 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5954 Py_DECREF_IMMORTAL(result);
5957 f = TP_RICHCOMPARE(type2);
5959 PyObject *result = (*f)(operand2, operand1, Py_GE);
5961 if (result != Py_NotImplemented) {
5962 Py_LeaveRecursiveCall();
5964 if (unlikely(result == NULL)) {
5965 return NUITKA_BOOL_EXCEPTION;
5969 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5975 Py_DECREF_IMMORTAL(result);
5981 cmpfunc fcmp = PyInt_Type.tp_compare;
5982 c = (*fcmp)(operand1, operand2);
5983 }
else if (PyInstance_Check(operand2)) {
5984 cmpfunc fcmp = type2->tp_compare;
5985 c = (*fcmp)(operand1, operand2);
5987 c = try_3way_compare(operand1, operand2);
5991 if (&PyInt_Type == type2) {
5992 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5993 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5995 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5996 }
else if (operand1 == Py_None) {
5999 }
else if (operand2 == Py_None) {
6002 }
else if (PyNumber_Check(operand1)) {
6005 if (PyNumber_Check(operand2)) {
6007 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
6008 Py_uintptr_t bb = (Py_uintptr_t)type2;
6010 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6014 }
else if (PyNumber_Check(operand2)) {
6018 int s = strcmp(
"int", type2->tp_name);
6026 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
6027 Py_uintptr_t bb = (Py_uintptr_t)type2;
6029 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6034 Py_LeaveRecursiveCall();
6036 if (unlikely(c <= -2)) {
6037 return NUITKA_BOOL_EXCEPTION;
6062 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6066 bool checked_reverse_op =
false;
6069 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
6070 f = TP_RICHCOMPARE(type2);
6073 checked_reverse_op =
true;
6075 PyObject *result = (*f)(operand2, operand1, Py_GE);
6077 if (result != Py_NotImplemented) {
6078 Py_LeaveRecursiveCall();
6080 if (unlikely(result == NULL)) {
6081 return NUITKA_BOOL_EXCEPTION;
6085 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6091 Py_DECREF_IMMORTAL(result);
6098 PyObject *result = (*f)(operand1, operand2, Py_LE);
6100 if (result != Py_NotImplemented) {
6101 Py_LeaveRecursiveCall();
6103 if (unlikely(result == NULL)) {
6104 return NUITKA_BOOL_EXCEPTION;
6108 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6114 Py_DECREF_IMMORTAL(result);
6117 if (checked_reverse_op ==
false) {
6118 f = TP_RICHCOMPARE(type2);
6121 PyObject *result = (*f)(operand2, operand1, Py_GE);
6123 if (result != Py_NotImplemented) {
6124 Py_LeaveRecursiveCall();
6126 if (unlikely(result == NULL)) {
6127 return NUITKA_BOOL_EXCEPTION;
6131 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6137 Py_DECREF_IMMORTAL(result);
6141 Py_LeaveRecursiveCall();
6147 bool r = operand1 == operand2;
6148 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6153 bool r = operand1 != operand2;
6154 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6159#if PYTHON_VERSION < 0x360
6160 PyErr_Format(PyExc_TypeError,
"unorderable types: int() <= %s()", type2->tp_name);
6162 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'int' and '%s'", type2->tp_name);
6164 return NUITKA_BOOL_EXCEPTION;
6170static PyObject *COMPARE_LE_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6171 CHECK_OBJECT(operand1);
6172 assert(PyLong_CheckExact(operand1));
6173 CHECK_OBJECT(operand2);
6174 assert(PyLong_CheckExact(operand2));
6176 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
6178 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
6182 if (operand1_long_object == operand2_long_object) {
6184 }
else if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
6185 Nuitka_LongGetSignedDigitSize(operand2_long_object)) {
6186 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - Nuitka_LongGetSignedDigitSize(operand2_long_object) <
6189 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
6192 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] !=
6193 Nuitka_LongGetDigitPointer(operand2_long_object)[i]) {
6194 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] <
6195 Nuitka_LongGetDigitPointer(operand2_long_object)[i];
6196 if (Nuitka_LongIsNegative(operand1_long_object)) {
6205 PyObject *result = BOOL_FROM(r);
6206 Py_INCREF_IMMORTAL(result);
6210PyObject *RICH_COMPARE_LE_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
6212 if (Py_TYPE(operand1) == &PyLong_Type) {
6213 return COMPARE_LE_OBJECT_LONG_LONG(operand1, operand2);
6216#if PYTHON_VERSION < 0x300
6217 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6221 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6226 PyTypeObject *type1 = Py_TYPE(operand1);
6228#if PYTHON_VERSION < 0x300
6230 if (type1 == &PyLong_Type && !0) {
6232 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6234 if (frich != NULL) {
6235 PyObject *result = (*frich)(operand1, operand2, Py_LE);
6237 if (result != Py_NotImplemented) {
6238 Py_LeaveRecursiveCall();
6243 Py_DECREF_IMMORTAL(result);
6247 cmpfunc fcmp = PyLong_Type.tp_compare;
6250 int c = (*fcmp)(operand1, operand2);
6251 c = adjust_tp_compare(c);
6253 Py_LeaveRecursiveCall();
6279 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6283 PyObject *result = BOOL_FROM(r);
6284 Py_INCREF_IMMORTAL(result);
6292 if (type1 != &PyLong_Type && 0) {
6293 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6296 PyObject *result = (*f)(operand2, operand1, Py_GE);
6298 if (result != Py_NotImplemented) {
6299 Py_LeaveRecursiveCall();
6304 Py_DECREF_IMMORTAL(result);
6308 f = TP_RICHCOMPARE(type1);
6310 PyObject *result = (*f)(operand1, operand2, Py_LE);
6312 if (result != Py_NotImplemented) {
6313 Py_LeaveRecursiveCall();
6318 Py_DECREF_IMMORTAL(result);
6321 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6323 PyObject *result = (*f)(operand2, operand1, Py_GE);
6325 if (result != Py_NotImplemented) {
6326 Py_LeaveRecursiveCall();
6331 Py_DECREF_IMMORTAL(result);
6336 if (PyInstance_Check(operand1)) {
6337 cmpfunc fcmp = type1->tp_compare;
6338 c = (*fcmp)(operand1, operand2);
6340 cmpfunc fcmp = PyLong_Type.tp_compare;
6341 c = (*fcmp)(operand1, operand2);
6343 c = try_3way_compare(operand1, operand2);
6347 if (type1 == &PyLong_Type) {
6348 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6349 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6351 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6352 }
else if (operand1 == Py_None) {
6355 }
else if (operand2 == Py_None) {
6358 }
else if (PyNumber_Check(operand1)) {
6361 if (PyNumber_Check(operand2)) {
6363 Py_uintptr_t aa = (Py_uintptr_t)type1;
6364 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6366 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6370 }
else if (PyNumber_Check(operand2)) {
6374 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"long" :
"int"));
6382 Py_uintptr_t aa = (Py_uintptr_t)type1;
6383 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6385 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6390 Py_LeaveRecursiveCall();
6392 if (unlikely(c <= -2)) {
6418 PyObject *result = BOOL_FROM(r);
6419 Py_INCREF_IMMORTAL(result);
6422 bool checked_reverse_op =
false;
6425 if (type1 != &PyLong_Type && Nuitka_Type_IsSubtype(&PyLong_Type, type1)) {
6426 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6429 checked_reverse_op =
true;
6431 PyObject *result = (*f)(operand2, operand1, Py_GE);
6433 if (result != Py_NotImplemented) {
6434 Py_LeaveRecursiveCall();
6439 Py_DECREF_IMMORTAL(result);
6443 f = TP_RICHCOMPARE(type1);
6446 PyObject *result = (*f)(operand1, operand2, Py_LE);
6448 if (result != Py_NotImplemented) {
6449 Py_LeaveRecursiveCall();
6454 Py_DECREF_IMMORTAL(result);
6457 if (checked_reverse_op ==
false) {
6458 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6461 PyObject *result = (*f)(operand2, operand1, Py_GE);
6463 if (result != Py_NotImplemented) {
6464 Py_LeaveRecursiveCall();
6469 Py_DECREF_IMMORTAL(result);
6473 Py_LeaveRecursiveCall();
6479 bool r = operand1 == operand2;
6480 PyObject *result = BOOL_FROM(r);
6481 Py_INCREF_IMMORTAL(result);
6485 bool r = operand1 != operand2;
6486 PyObject *result = BOOL_FROM(r);
6487 Py_INCREF_IMMORTAL(result);
6491#if PYTHON_VERSION < 0x300
6492 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= long()", type1->tp_name);
6493#elif PYTHON_VERSION < 0x360
6494 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= int()", type1->tp_name);
6496 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'int'", type1->tp_name);
6504PyObject *RICH_COMPARE_LE_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
6506 if (&PyLong_Type == Py_TYPE(operand2)) {
6507 return COMPARE_LE_OBJECT_LONG_LONG(operand1, operand2);
6510#if PYTHON_VERSION < 0x300
6511 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6515 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6520 PyTypeObject *type2 = Py_TYPE(operand2);
6522#if PYTHON_VERSION < 0x300
6524 if (&PyLong_Type == type2 && !0) {
6526 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6528 if (frich != NULL) {
6529 PyObject *result = (*frich)(operand1, operand2, Py_LE);
6531 if (result != Py_NotImplemented) {
6532 Py_LeaveRecursiveCall();
6537 Py_DECREF_IMMORTAL(result);
6541 cmpfunc fcmp = PyLong_Type.tp_compare;
6544 int c = (*fcmp)(operand1, operand2);
6545 c = adjust_tp_compare(c);
6547 Py_LeaveRecursiveCall();
6573 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6577 PyObject *result = BOOL_FROM(r);
6578 Py_INCREF_IMMORTAL(result);
6586 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
6587 f = TP_RICHCOMPARE(type2);
6590 PyObject *result = (*f)(operand2, operand1, Py_GE);
6592 if (result != Py_NotImplemented) {
6593 Py_LeaveRecursiveCall();
6598 Py_DECREF_IMMORTAL(result);
6602 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6604 PyObject *result = (*f)(operand1, operand2, Py_LE);
6606 if (result != Py_NotImplemented) {
6607 Py_LeaveRecursiveCall();
6612 Py_DECREF_IMMORTAL(result);
6615 f = TP_RICHCOMPARE(type2);
6617 PyObject *result = (*f)(operand2, operand1, Py_GE);
6619 if (result != Py_NotImplemented) {
6620 Py_LeaveRecursiveCall();
6625 Py_DECREF_IMMORTAL(result);
6631 cmpfunc fcmp = PyLong_Type.tp_compare;
6632 c = (*fcmp)(operand1, operand2);
6633 }
else if (PyInstance_Check(operand2)) {
6634 cmpfunc fcmp = type2->tp_compare;
6635 c = (*fcmp)(operand1, operand2);
6637 c = try_3way_compare(operand1, operand2);
6641 if (&PyLong_Type == type2) {
6642 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6643 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6645 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6646 }
else if (operand1 == Py_None) {
6649 }
else if (operand2 == Py_None) {
6652 }
else if (PyNumber_Check(operand1)) {
6655 if (PyNumber_Check(operand2)) {
6657 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
6658 Py_uintptr_t bb = (Py_uintptr_t)type2;
6660 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6664 }
else if (PyNumber_Check(operand2)) {
6668 int s = strcmp((PYTHON_VERSION < 0x300 ?
"long" :
"int"), type2->tp_name);
6676 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
6677 Py_uintptr_t bb = (Py_uintptr_t)type2;
6679 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6684 Py_LeaveRecursiveCall();
6686 if (unlikely(c <= -2)) {
6712 PyObject *result = BOOL_FROM(r);
6713 Py_INCREF_IMMORTAL(result);
6716 bool checked_reverse_op =
false;
6719 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
6720 f = TP_RICHCOMPARE(type2);
6723 checked_reverse_op =
true;
6725 PyObject *result = (*f)(operand2, operand1, Py_GE);
6727 if (result != Py_NotImplemented) {
6728 Py_LeaveRecursiveCall();
6733 Py_DECREF_IMMORTAL(result);
6737 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6740 PyObject *result = (*f)(operand1, operand2, Py_LE);
6742 if (result != Py_NotImplemented) {
6743 Py_LeaveRecursiveCall();
6748 Py_DECREF_IMMORTAL(result);
6751 if (checked_reverse_op ==
false) {
6752 f = TP_RICHCOMPARE(type2);
6755 PyObject *result = (*f)(operand2, operand1, Py_GE);
6757 if (result != Py_NotImplemented) {
6758 Py_LeaveRecursiveCall();
6763 Py_DECREF_IMMORTAL(result);
6767 Py_LeaveRecursiveCall();
6773 bool r = operand1 == operand2;
6774 PyObject *result = BOOL_FROM(r);
6775 Py_INCREF_IMMORTAL(result);
6779 bool r = operand1 != operand2;
6780 PyObject *result = BOOL_FROM(r);
6781 Py_INCREF_IMMORTAL(result);
6785#if PYTHON_VERSION < 0x300
6786 PyErr_Format(PyExc_TypeError,
"unorderable types: long() <= %s()", type2->tp_name);
6787#elif PYTHON_VERSION < 0x360
6788 PyErr_Format(PyExc_TypeError,
"unorderable types: int() <= %s()", type2->tp_name);
6790 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'int' and '%s'", type2->tp_name);
6798PyObject *RICH_COMPARE_LE_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6800 return COMPARE_LE_OBJECT_LONG_LONG(operand1, operand2);
6803static bool COMPARE_LE_CBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6804 CHECK_OBJECT(operand1);
6805 assert(PyLong_CheckExact(operand1));
6806 CHECK_OBJECT(operand2);
6807 assert(PyLong_CheckExact(operand2));
6809 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
6811 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
6815 if (operand1_long_object == operand2_long_object) {
6817 }
else if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
6818 Nuitka_LongGetSignedDigitSize(operand2_long_object)) {
6819 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - Nuitka_LongGetSignedDigitSize(operand2_long_object) <
6822 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
6825 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] !=
6826 Nuitka_LongGetDigitPointer(operand2_long_object)[i]) {
6827 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] <
6828 Nuitka_LongGetDigitPointer(operand2_long_object)[i];
6829 if (Nuitka_LongIsNegative(operand1_long_object)) {
6843bool RICH_COMPARE_LE_CBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6845 return COMPARE_LE_CBOOL_LONG_LONG(operand1, operand2);
6849nuitka_bool RICH_COMPARE_LE_NBOOL_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
6851 if (Py_TYPE(operand1) == &PyLong_Type) {
6852 return COMPARE_LE_CBOOL_LONG_LONG(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6855#if PYTHON_VERSION < 0x300
6856 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6857 return NUITKA_BOOL_EXCEPTION;
6860 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6861 return NUITKA_BOOL_EXCEPTION;
6865 PyTypeObject *type1 = Py_TYPE(operand1);
6867#if PYTHON_VERSION < 0x300
6869 if (type1 == &PyLong_Type && !0) {
6871 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6873 if (frich != NULL) {
6874 PyObject *result = (*frich)(operand1, operand2, Py_LE);
6876 if (result != Py_NotImplemented) {
6877 Py_LeaveRecursiveCall();
6879 if (unlikely(result == NULL)) {
6880 return NUITKA_BOOL_EXCEPTION;
6884 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6890 Py_DECREF_IMMORTAL(result);
6894 cmpfunc fcmp = PyLong_Type.tp_compare;
6897 int c = (*fcmp)(operand1, operand2);
6898 c = adjust_tp_compare(c);
6900 Py_LeaveRecursiveCall();
6903 return NUITKA_BOOL_EXCEPTION;
6926 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6930 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6939 if (type1 != &PyLong_Type && 0) {
6940 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6943 PyObject *result = (*f)(operand2, operand1, Py_GE);
6945 if (result != Py_NotImplemented) {
6946 Py_LeaveRecursiveCall();
6948 if (unlikely(result == NULL)) {
6949 return NUITKA_BOOL_EXCEPTION;
6953 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6959 Py_DECREF_IMMORTAL(result);
6963 f = TP_RICHCOMPARE(type1);
6965 PyObject *result = (*f)(operand1, operand2, Py_LE);
6967 if (result != Py_NotImplemented) {
6968 Py_LeaveRecursiveCall();
6970 if (unlikely(result == NULL)) {
6971 return NUITKA_BOOL_EXCEPTION;
6975 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6981 Py_DECREF_IMMORTAL(result);
6984 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6986 PyObject *result = (*f)(operand2, operand1, Py_GE);
6988 if (result != Py_NotImplemented) {
6989 Py_LeaveRecursiveCall();
6991 if (unlikely(result == NULL)) {
6992 return NUITKA_BOOL_EXCEPTION;
6996 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7002 Py_DECREF_IMMORTAL(result);
7007 if (PyInstance_Check(operand1)) {
7008 cmpfunc fcmp = type1->tp_compare;
7009 c = (*fcmp)(operand1, operand2);
7011 cmpfunc fcmp = PyLong_Type.tp_compare;
7012 c = (*fcmp)(operand1, operand2);
7014 c = try_3way_compare(operand1, operand2);
7018 if (type1 == &PyLong_Type) {
7019 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7020 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7022 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7023 }
else if (operand1 == Py_None) {
7026 }
else if (operand2 == Py_None) {
7029 }
else if (PyNumber_Check(operand1)) {
7032 if (PyNumber_Check(operand2)) {
7034 Py_uintptr_t aa = (Py_uintptr_t)type1;
7035 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
7037 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7041 }
else if (PyNumber_Check(operand2)) {
7045 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"long" :
"int"));
7053 Py_uintptr_t aa = (Py_uintptr_t)type1;
7054 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
7056 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7061 Py_LeaveRecursiveCall();
7063 if (unlikely(c <= -2)) {
7064 return NUITKA_BOOL_EXCEPTION;
7089 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7093 bool checked_reverse_op =
false;
7096 if (type1 != &PyLong_Type && Nuitka_Type_IsSubtype(&PyLong_Type, type1)) {
7097 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7100 checked_reverse_op =
true;
7102 PyObject *result = (*f)(operand2, operand1, Py_GE);
7104 if (result != Py_NotImplemented) {
7105 Py_LeaveRecursiveCall();
7107 if (unlikely(result == NULL)) {
7108 return NUITKA_BOOL_EXCEPTION;
7112 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7118 Py_DECREF_IMMORTAL(result);
7122 f = TP_RICHCOMPARE(type1);
7125 PyObject *result = (*f)(operand1, operand2, Py_LE);
7127 if (result != Py_NotImplemented) {
7128 Py_LeaveRecursiveCall();
7130 if (unlikely(result == NULL)) {
7131 return NUITKA_BOOL_EXCEPTION;
7135 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7141 Py_DECREF_IMMORTAL(result);
7144 if (checked_reverse_op ==
false) {
7145 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7148 PyObject *result = (*f)(operand2, operand1, Py_GE);
7150 if (result != Py_NotImplemented) {
7151 Py_LeaveRecursiveCall();
7153 if (unlikely(result == NULL)) {
7154 return NUITKA_BOOL_EXCEPTION;
7158 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7164 Py_DECREF_IMMORTAL(result);
7168 Py_LeaveRecursiveCall();
7174 bool r = operand1 == operand2;
7175 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7180 bool r = operand1 != operand2;
7181 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7186#if PYTHON_VERSION < 0x300
7187 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= long()", type1->tp_name);
7188#elif PYTHON_VERSION < 0x360
7189 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= int()", type1->tp_name);
7191 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'int'", type1->tp_name);
7193 return NUITKA_BOOL_EXCEPTION;
7199nuitka_bool RICH_COMPARE_LE_NBOOL_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
7201 if (&PyLong_Type == Py_TYPE(operand2)) {
7202 return COMPARE_LE_CBOOL_LONG_LONG(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7205#if PYTHON_VERSION < 0x300
7206 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7207 return NUITKA_BOOL_EXCEPTION;
7210 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7211 return NUITKA_BOOL_EXCEPTION;
7215 PyTypeObject *type2 = Py_TYPE(operand2);
7217#if PYTHON_VERSION < 0x300
7219 if (&PyLong_Type == type2 && !0) {
7221 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7223 if (frich != NULL) {
7224 PyObject *result = (*frich)(operand1, operand2, Py_LE);
7226 if (result != Py_NotImplemented) {
7227 Py_LeaveRecursiveCall();
7229 if (unlikely(result == NULL)) {
7230 return NUITKA_BOOL_EXCEPTION;
7234 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7240 Py_DECREF_IMMORTAL(result);
7244 cmpfunc fcmp = PyLong_Type.tp_compare;
7247 int c = (*fcmp)(operand1, operand2);
7248 c = adjust_tp_compare(c);
7250 Py_LeaveRecursiveCall();
7253 return NUITKA_BOOL_EXCEPTION;
7276 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7280 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7289 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
7290 f = TP_RICHCOMPARE(type2);
7293 PyObject *result = (*f)(operand2, operand1, Py_GE);
7295 if (result != Py_NotImplemented) {
7296 Py_LeaveRecursiveCall();
7298 if (unlikely(result == NULL)) {
7299 return NUITKA_BOOL_EXCEPTION;
7303 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7309 Py_DECREF_IMMORTAL(result);
7313 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7315 PyObject *result = (*f)(operand1, operand2, Py_LE);
7317 if (result != Py_NotImplemented) {
7318 Py_LeaveRecursiveCall();
7320 if (unlikely(result == NULL)) {
7321 return NUITKA_BOOL_EXCEPTION;
7325 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7331 Py_DECREF_IMMORTAL(result);
7334 f = TP_RICHCOMPARE(type2);
7336 PyObject *result = (*f)(operand2, operand1, Py_GE);
7338 if (result != Py_NotImplemented) {
7339 Py_LeaveRecursiveCall();
7341 if (unlikely(result == NULL)) {
7342 return NUITKA_BOOL_EXCEPTION;
7346 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7352 Py_DECREF_IMMORTAL(result);
7358 cmpfunc fcmp = PyLong_Type.tp_compare;
7359 c = (*fcmp)(operand1, operand2);
7360 }
else if (PyInstance_Check(operand2)) {
7361 cmpfunc fcmp = type2->tp_compare;
7362 c = (*fcmp)(operand1, operand2);
7364 c = try_3way_compare(operand1, operand2);
7368 if (&PyLong_Type == type2) {
7369 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7370 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7372 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7373 }
else if (operand1 == Py_None) {
7376 }
else if (operand2 == Py_None) {
7379 }
else if (PyNumber_Check(operand1)) {
7382 if (PyNumber_Check(operand2)) {
7384 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
7385 Py_uintptr_t bb = (Py_uintptr_t)type2;
7387 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7391 }
else if (PyNumber_Check(operand2)) {
7395 int s = strcmp((PYTHON_VERSION < 0x300 ?
"long" :
"int"), type2->tp_name);
7403 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
7404 Py_uintptr_t bb = (Py_uintptr_t)type2;
7406 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7411 Py_LeaveRecursiveCall();
7413 if (unlikely(c <= -2)) {
7414 return NUITKA_BOOL_EXCEPTION;
7439 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7443 bool checked_reverse_op =
false;
7446 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
7447 f = TP_RICHCOMPARE(type2);
7450 checked_reverse_op =
true;
7452 PyObject *result = (*f)(operand2, operand1, Py_GE);
7454 if (result != Py_NotImplemented) {
7455 Py_LeaveRecursiveCall();
7457 if (unlikely(result == NULL)) {
7458 return NUITKA_BOOL_EXCEPTION;
7462 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7468 Py_DECREF_IMMORTAL(result);
7472 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7475 PyObject *result = (*f)(operand1, operand2, Py_LE);
7477 if (result != Py_NotImplemented) {
7478 Py_LeaveRecursiveCall();
7480 if (unlikely(result == NULL)) {
7481 return NUITKA_BOOL_EXCEPTION;
7485 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7491 Py_DECREF_IMMORTAL(result);
7494 if (checked_reverse_op ==
false) {
7495 f = TP_RICHCOMPARE(type2);
7498 PyObject *result = (*f)(operand2, operand1, Py_GE);
7500 if (result != Py_NotImplemented) {
7501 Py_LeaveRecursiveCall();
7503 if (unlikely(result == NULL)) {
7504 return NUITKA_BOOL_EXCEPTION;
7508 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7514 Py_DECREF_IMMORTAL(result);
7518 Py_LeaveRecursiveCall();
7524 bool r = operand1 == operand2;
7525 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7530 bool r = operand1 != operand2;
7531 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7536#if PYTHON_VERSION < 0x300
7537 PyErr_Format(PyExc_TypeError,
"unorderable types: long() <= %s()", type2->tp_name);
7538#elif PYTHON_VERSION < 0x360
7539 PyErr_Format(PyExc_TypeError,
"unorderable types: int() <= %s()", type2->tp_name);
7541 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'int' and '%s'", type2->tp_name);
7543 return NUITKA_BOOL_EXCEPTION;
7548static PyObject *COMPARE_LE_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
7549 CHECK_OBJECT(operand1);
7550 assert(PyFloat_CheckExact(operand1));
7551 CHECK_OBJECT(operand2);
7552 assert(PyFloat_CheckExact(operand2));
7554 const double a = PyFloat_AS_DOUBLE(operand1);
7555 const double b = PyFloat_AS_DOUBLE(operand2);
7560 PyObject *result = BOOL_FROM(r);
7561 Py_INCREF_IMMORTAL(result);
7565PyObject *RICH_COMPARE_LE_OBJECT_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
7567 if (Py_TYPE(operand1) == &PyFloat_Type) {
7568 return COMPARE_LE_OBJECT_FLOAT_FLOAT(operand1, operand2);
7571#if PYTHON_VERSION < 0x300
7572 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7576 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7581 PyTypeObject *type1 = Py_TYPE(operand1);
7583#if PYTHON_VERSION < 0x300
7585 if (type1 == &PyFloat_Type && !0) {
7587 richcmpfunc frich = PyFloat_Type.tp_richcompare;
7589 if (frich != NULL) {
7590 PyObject *result = (*frich)(operand1, operand2, Py_LE);
7592 if (result != Py_NotImplemented) {
7593 Py_LeaveRecursiveCall();
7598 Py_DECREF_IMMORTAL(result);
7602 cmpfunc fcmp = NULL;
7605 int c = (*fcmp)(operand1, operand2);
7606 c = adjust_tp_compare(c);
7608 Py_LeaveRecursiveCall();
7634 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7638 PyObject *result = BOOL_FROM(r);
7639 Py_INCREF_IMMORTAL(result);
7647 if (type1 != &PyFloat_Type && 0) {
7648 f = PyFloat_Type.tp_richcompare;
7651 PyObject *result = (*f)(operand2, operand1, Py_GE);
7653 if (result != Py_NotImplemented) {
7654 Py_LeaveRecursiveCall();
7659 Py_DECREF_IMMORTAL(result);
7663 f = TP_RICHCOMPARE(type1);
7665 PyObject *result = (*f)(operand1, operand2, Py_LE);
7667 if (result != Py_NotImplemented) {
7668 Py_LeaveRecursiveCall();
7673 Py_DECREF_IMMORTAL(result);
7676 f = PyFloat_Type.tp_richcompare;
7678 PyObject *result = (*f)(operand2, operand1, Py_GE);
7680 if (result != Py_NotImplemented) {
7681 Py_LeaveRecursiveCall();
7686 Py_DECREF_IMMORTAL(result);
7691 if (PyInstance_Check(operand1)) {
7692 cmpfunc fcmp = type1->tp_compare;
7693 c = (*fcmp)(operand1, operand2);
7695 cmpfunc fcmp = NULL;
7696 c = (*fcmp)(operand1, operand2);
7698 c = try_3way_compare(operand1, operand2);
7702 if (type1 == &PyFloat_Type) {
7703 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7704 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7706 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7707 }
else if (operand1 == Py_None) {
7710 }
else if (operand2 == Py_None) {
7713 }
else if (PyNumber_Check(operand1)) {
7716 if (PyNumber_Check(operand2)) {
7718 Py_uintptr_t aa = (Py_uintptr_t)type1;
7719 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
7721 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7725 }
else if (PyNumber_Check(operand2)) {
7729 int s = strcmp(type1->tp_name,
"float");
7737 Py_uintptr_t aa = (Py_uintptr_t)type1;
7738 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
7740 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7745 Py_LeaveRecursiveCall();
7747 if (unlikely(c <= -2)) {
7773 PyObject *result = BOOL_FROM(r);
7774 Py_INCREF_IMMORTAL(result);
7777 bool checked_reverse_op =
false;
7780 if (type1 != &PyFloat_Type && Nuitka_Type_IsSubtype(&PyFloat_Type, type1)) {
7781 f = PyFloat_Type.tp_richcompare;
7784 checked_reverse_op =
true;
7786 PyObject *result = (*f)(operand2, operand1, Py_GE);
7788 if (result != Py_NotImplemented) {
7789 Py_LeaveRecursiveCall();
7794 Py_DECREF_IMMORTAL(result);
7798 f = TP_RICHCOMPARE(type1);
7801 PyObject *result = (*f)(operand1, operand2, Py_LE);
7803 if (result != Py_NotImplemented) {
7804 Py_LeaveRecursiveCall();
7809 Py_DECREF_IMMORTAL(result);
7812 if (checked_reverse_op ==
false) {
7813 f = PyFloat_Type.tp_richcompare;
7816 PyObject *result = (*f)(operand2, operand1, Py_GE);
7818 if (result != Py_NotImplemented) {
7819 Py_LeaveRecursiveCall();
7824 Py_DECREF_IMMORTAL(result);
7828 Py_LeaveRecursiveCall();
7834 bool r = operand1 == operand2;
7835 PyObject *result = BOOL_FROM(r);
7836 Py_INCREF_IMMORTAL(result);
7840 bool r = operand1 != operand2;
7841 PyObject *result = BOOL_FROM(r);
7842 Py_INCREF_IMMORTAL(result);
7846#if PYTHON_VERSION < 0x360
7847 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= float()", type1->tp_name);
7849 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'float'", type1->tp_name);
7857PyObject *RICH_COMPARE_LE_OBJECT_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
7859 if (&PyFloat_Type == Py_TYPE(operand2)) {
7860 return COMPARE_LE_OBJECT_FLOAT_FLOAT(operand1, operand2);
7863#if PYTHON_VERSION < 0x300
7864 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7868 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7873 PyTypeObject *type2 = Py_TYPE(operand2);
7875#if PYTHON_VERSION < 0x300
7877 if (&PyFloat_Type == type2 && !0) {
7879 richcmpfunc frich = PyFloat_Type.tp_richcompare;
7881 if (frich != NULL) {
7882 PyObject *result = (*frich)(operand1, operand2, Py_LE);
7884 if (result != Py_NotImplemented) {
7885 Py_LeaveRecursiveCall();
7890 Py_DECREF_IMMORTAL(result);
7894 cmpfunc fcmp = NULL;
7897 int c = (*fcmp)(operand1, operand2);
7898 c = adjust_tp_compare(c);
7900 Py_LeaveRecursiveCall();
7926 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7930 PyObject *result = BOOL_FROM(r);
7931 Py_INCREF_IMMORTAL(result);
7939 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
7940 f = TP_RICHCOMPARE(type2);
7943 PyObject *result = (*f)(operand2, operand1, Py_GE);
7945 if (result != Py_NotImplemented) {
7946 Py_LeaveRecursiveCall();
7951 Py_DECREF_IMMORTAL(result);
7955 f = PyFloat_Type.tp_richcompare;
7957 PyObject *result = (*f)(operand1, operand2, Py_LE);
7959 if (result != Py_NotImplemented) {
7960 Py_LeaveRecursiveCall();
7965 Py_DECREF_IMMORTAL(result);
7968 f = TP_RICHCOMPARE(type2);
7970 PyObject *result = (*f)(operand2, operand1, Py_GE);
7972 if (result != Py_NotImplemented) {
7973 Py_LeaveRecursiveCall();
7978 Py_DECREF_IMMORTAL(result);
7984 cmpfunc fcmp = NULL;
7985 c = (*fcmp)(operand1, operand2);
7986 }
else if (PyInstance_Check(operand2)) {
7987 cmpfunc fcmp = type2->tp_compare;
7988 c = (*fcmp)(operand1, operand2);
7990 c = try_3way_compare(operand1, operand2);
7994 if (&PyFloat_Type == type2) {
7995 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7996 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7998 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7999 }
else if (operand1 == Py_None) {
8002 }
else if (operand2 == Py_None) {
8005 }
else if (PyNumber_Check(operand1)) {
8008 if (PyNumber_Check(operand2)) {
8010 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8011 Py_uintptr_t bb = (Py_uintptr_t)type2;
8013 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8017 }
else if (PyNumber_Check(operand2)) {
8021 int s = strcmp(
"float", type2->tp_name);
8029 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8030 Py_uintptr_t bb = (Py_uintptr_t)type2;
8032 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8037 Py_LeaveRecursiveCall();
8039 if (unlikely(c <= -2)) {
8065 PyObject *result = BOOL_FROM(r);
8066 Py_INCREF_IMMORTAL(result);
8069 bool checked_reverse_op =
false;
8072 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8073 f = TP_RICHCOMPARE(type2);
8076 checked_reverse_op =
true;
8078 PyObject *result = (*f)(operand2, operand1, Py_GE);
8080 if (result != Py_NotImplemented) {
8081 Py_LeaveRecursiveCall();
8086 Py_DECREF_IMMORTAL(result);
8090 f = PyFloat_Type.tp_richcompare;
8093 PyObject *result = (*f)(operand1, operand2, Py_LE);
8095 if (result != Py_NotImplemented) {
8096 Py_LeaveRecursiveCall();
8101 Py_DECREF_IMMORTAL(result);
8104 if (checked_reverse_op ==
false) {
8105 f = TP_RICHCOMPARE(type2);
8108 PyObject *result = (*f)(operand2, operand1, Py_GE);
8110 if (result != Py_NotImplemented) {
8111 Py_LeaveRecursiveCall();
8116 Py_DECREF_IMMORTAL(result);
8120 Py_LeaveRecursiveCall();
8126 bool r = operand1 == operand2;
8127 PyObject *result = BOOL_FROM(r);
8128 Py_INCREF_IMMORTAL(result);
8132 bool r = operand1 != operand2;
8133 PyObject *result = BOOL_FROM(r);
8134 Py_INCREF_IMMORTAL(result);
8138#if PYTHON_VERSION < 0x360
8139 PyErr_Format(PyExc_TypeError,
"unorderable types: float() <= %s()", type2->tp_name);
8141 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'float' and '%s'", type2->tp_name);
8149PyObject *RICH_COMPARE_LE_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8151 return COMPARE_LE_OBJECT_FLOAT_FLOAT(operand1, operand2);
8154static bool COMPARE_LE_CBOOL_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8155 CHECK_OBJECT(operand1);
8156 assert(PyFloat_CheckExact(operand1));
8157 CHECK_OBJECT(operand2);
8158 assert(PyFloat_CheckExact(operand2));
8160 const double a = PyFloat_AS_DOUBLE(operand1);
8161 const double b = PyFloat_AS_DOUBLE(operand2);
8171bool RICH_COMPARE_LE_CBOOL_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8173 return COMPARE_LE_CBOOL_FLOAT_FLOAT(operand1, operand2);
8177nuitka_bool RICH_COMPARE_LE_NBOOL_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
8179 if (Py_TYPE(operand1) == &PyFloat_Type) {
8180 return COMPARE_LE_CBOOL_FLOAT_FLOAT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8183#if PYTHON_VERSION < 0x300
8184 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8185 return NUITKA_BOOL_EXCEPTION;
8188 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8189 return NUITKA_BOOL_EXCEPTION;
8193 PyTypeObject *type1 = Py_TYPE(operand1);
8195#if PYTHON_VERSION < 0x300
8197 if (type1 == &PyFloat_Type && !0) {
8199 richcmpfunc frich = PyFloat_Type.tp_richcompare;
8201 if (frich != NULL) {
8202 PyObject *result = (*frich)(operand1, operand2, Py_LE);
8204 if (result != Py_NotImplemented) {
8205 Py_LeaveRecursiveCall();
8207 if (unlikely(result == NULL)) {
8208 return NUITKA_BOOL_EXCEPTION;
8212 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8218 Py_DECREF_IMMORTAL(result);
8222 cmpfunc fcmp = NULL;
8225 int c = (*fcmp)(operand1, operand2);
8226 c = adjust_tp_compare(c);
8228 Py_LeaveRecursiveCall();
8231 return NUITKA_BOOL_EXCEPTION;
8254 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8258 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8267 if (type1 != &PyFloat_Type && 0) {
8268 f = PyFloat_Type.tp_richcompare;
8271 PyObject *result = (*f)(operand2, operand1, Py_GE);
8273 if (result != Py_NotImplemented) {
8274 Py_LeaveRecursiveCall();
8276 if (unlikely(result == NULL)) {
8277 return NUITKA_BOOL_EXCEPTION;
8281 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8287 Py_DECREF_IMMORTAL(result);
8291 f = TP_RICHCOMPARE(type1);
8293 PyObject *result = (*f)(operand1, operand2, Py_LE);
8295 if (result != Py_NotImplemented) {
8296 Py_LeaveRecursiveCall();
8298 if (unlikely(result == NULL)) {
8299 return NUITKA_BOOL_EXCEPTION;
8303 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8309 Py_DECREF_IMMORTAL(result);
8312 f = PyFloat_Type.tp_richcompare;
8314 PyObject *result = (*f)(operand2, operand1, Py_GE);
8316 if (result != Py_NotImplemented) {
8317 Py_LeaveRecursiveCall();
8319 if (unlikely(result == NULL)) {
8320 return NUITKA_BOOL_EXCEPTION;
8324 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8330 Py_DECREF_IMMORTAL(result);
8335 if (PyInstance_Check(operand1)) {
8336 cmpfunc fcmp = type1->tp_compare;
8337 c = (*fcmp)(operand1, operand2);
8339 cmpfunc fcmp = NULL;
8340 c = (*fcmp)(operand1, operand2);
8342 c = try_3way_compare(operand1, operand2);
8346 if (type1 == &PyFloat_Type) {
8347 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8348 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8350 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8351 }
else if (operand1 == Py_None) {
8354 }
else if (operand2 == Py_None) {
8357 }
else if (PyNumber_Check(operand1)) {
8360 if (PyNumber_Check(operand2)) {
8362 Py_uintptr_t aa = (Py_uintptr_t)type1;
8363 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
8365 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8369 }
else if (PyNumber_Check(operand2)) {
8373 int s = strcmp(type1->tp_name,
"float");
8381 Py_uintptr_t aa = (Py_uintptr_t)type1;
8382 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
8384 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8389 Py_LeaveRecursiveCall();
8391 if (unlikely(c <= -2)) {
8392 return NUITKA_BOOL_EXCEPTION;
8417 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8421 bool checked_reverse_op =
false;
8424 if (type1 != &PyFloat_Type && Nuitka_Type_IsSubtype(&PyFloat_Type, type1)) {
8425 f = PyFloat_Type.tp_richcompare;
8428 checked_reverse_op =
true;
8430 PyObject *result = (*f)(operand2, operand1, Py_GE);
8432 if (result != Py_NotImplemented) {
8433 Py_LeaveRecursiveCall();
8435 if (unlikely(result == NULL)) {
8436 return NUITKA_BOOL_EXCEPTION;
8440 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8446 Py_DECREF_IMMORTAL(result);
8450 f = TP_RICHCOMPARE(type1);
8453 PyObject *result = (*f)(operand1, operand2, Py_LE);
8455 if (result != Py_NotImplemented) {
8456 Py_LeaveRecursiveCall();
8458 if (unlikely(result == NULL)) {
8459 return NUITKA_BOOL_EXCEPTION;
8463 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8469 Py_DECREF_IMMORTAL(result);
8472 if (checked_reverse_op ==
false) {
8473 f = PyFloat_Type.tp_richcompare;
8476 PyObject *result = (*f)(operand2, operand1, Py_GE);
8478 if (result != Py_NotImplemented) {
8479 Py_LeaveRecursiveCall();
8481 if (unlikely(result == NULL)) {
8482 return NUITKA_BOOL_EXCEPTION;
8486 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8492 Py_DECREF_IMMORTAL(result);
8496 Py_LeaveRecursiveCall();
8502 bool r = operand1 == operand2;
8503 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8508 bool r = operand1 != operand2;
8509 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8514#if PYTHON_VERSION < 0x360
8515 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= float()", type1->tp_name);
8517 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'float'", type1->tp_name);
8519 return NUITKA_BOOL_EXCEPTION;
8525nuitka_bool RICH_COMPARE_LE_NBOOL_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
8527 if (&PyFloat_Type == Py_TYPE(operand2)) {
8528 return COMPARE_LE_CBOOL_FLOAT_FLOAT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8531#if PYTHON_VERSION < 0x300
8532 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8533 return NUITKA_BOOL_EXCEPTION;
8536 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8537 return NUITKA_BOOL_EXCEPTION;
8541 PyTypeObject *type2 = Py_TYPE(operand2);
8543#if PYTHON_VERSION < 0x300
8545 if (&PyFloat_Type == type2 && !0) {
8547 richcmpfunc frich = PyFloat_Type.tp_richcompare;
8549 if (frich != NULL) {
8550 PyObject *result = (*frich)(operand1, operand2, Py_LE);
8552 if (result != Py_NotImplemented) {
8553 Py_LeaveRecursiveCall();
8555 if (unlikely(result == NULL)) {
8556 return NUITKA_BOOL_EXCEPTION;
8560 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8566 Py_DECREF_IMMORTAL(result);
8570 cmpfunc fcmp = NULL;
8573 int c = (*fcmp)(operand1, operand2);
8574 c = adjust_tp_compare(c);
8576 Py_LeaveRecursiveCall();
8579 return NUITKA_BOOL_EXCEPTION;
8602 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8606 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8615 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8616 f = TP_RICHCOMPARE(type2);
8619 PyObject *result = (*f)(operand2, operand1, Py_GE);
8621 if (result != Py_NotImplemented) {
8622 Py_LeaveRecursiveCall();
8624 if (unlikely(result == NULL)) {
8625 return NUITKA_BOOL_EXCEPTION;
8629 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8635 Py_DECREF_IMMORTAL(result);
8639 f = PyFloat_Type.tp_richcompare;
8641 PyObject *result = (*f)(operand1, operand2, Py_LE);
8643 if (result != Py_NotImplemented) {
8644 Py_LeaveRecursiveCall();
8646 if (unlikely(result == NULL)) {
8647 return NUITKA_BOOL_EXCEPTION;
8651 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8657 Py_DECREF_IMMORTAL(result);
8660 f = TP_RICHCOMPARE(type2);
8662 PyObject *result = (*f)(operand2, operand1, Py_GE);
8664 if (result != Py_NotImplemented) {
8665 Py_LeaveRecursiveCall();
8667 if (unlikely(result == NULL)) {
8668 return NUITKA_BOOL_EXCEPTION;
8672 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8678 Py_DECREF_IMMORTAL(result);
8684 cmpfunc fcmp = NULL;
8685 c = (*fcmp)(operand1, operand2);
8686 }
else if (PyInstance_Check(operand2)) {
8687 cmpfunc fcmp = type2->tp_compare;
8688 c = (*fcmp)(operand1, operand2);
8690 c = try_3way_compare(operand1, operand2);
8694 if (&PyFloat_Type == type2) {
8695 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8696 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8698 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8699 }
else if (operand1 == Py_None) {
8702 }
else if (operand2 == Py_None) {
8705 }
else if (PyNumber_Check(operand1)) {
8708 if (PyNumber_Check(operand2)) {
8710 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8711 Py_uintptr_t bb = (Py_uintptr_t)type2;
8713 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8717 }
else if (PyNumber_Check(operand2)) {
8721 int s = strcmp(
"float", type2->tp_name);
8729 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8730 Py_uintptr_t bb = (Py_uintptr_t)type2;
8732 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8737 Py_LeaveRecursiveCall();
8739 if (unlikely(c <= -2)) {
8740 return NUITKA_BOOL_EXCEPTION;
8765 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8769 bool checked_reverse_op =
false;
8772 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8773 f = TP_RICHCOMPARE(type2);
8776 checked_reverse_op =
true;
8778 PyObject *result = (*f)(operand2, operand1, Py_GE);
8780 if (result != Py_NotImplemented) {
8781 Py_LeaveRecursiveCall();
8783 if (unlikely(result == NULL)) {
8784 return NUITKA_BOOL_EXCEPTION;
8788 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8794 Py_DECREF_IMMORTAL(result);
8798 f = PyFloat_Type.tp_richcompare;
8801 PyObject *result = (*f)(operand1, operand2, Py_LE);
8803 if (result != Py_NotImplemented) {
8804 Py_LeaveRecursiveCall();
8806 if (unlikely(result == NULL)) {
8807 return NUITKA_BOOL_EXCEPTION;
8811 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8817 Py_DECREF_IMMORTAL(result);
8820 if (checked_reverse_op ==
false) {
8821 f = TP_RICHCOMPARE(type2);
8824 PyObject *result = (*f)(operand2, operand1, Py_GE);
8826 if (result != Py_NotImplemented) {
8827 Py_LeaveRecursiveCall();
8829 if (unlikely(result == NULL)) {
8830 return NUITKA_BOOL_EXCEPTION;
8834 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8840 Py_DECREF_IMMORTAL(result);
8844 Py_LeaveRecursiveCall();
8850 bool r = operand1 == operand2;
8851 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8856 bool r = operand1 != operand2;
8857 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8862#if PYTHON_VERSION < 0x360
8863 PyErr_Format(PyExc_TypeError,
"unorderable types: float() <= %s()", type2->tp_name);
8865 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'float' and '%s'", type2->tp_name);
8867 return NUITKA_BOOL_EXCEPTION;
8872static PyObject *COMPARE_LE_OBJECT_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
8873 CHECK_OBJECT(operand1);
8874 assert(PyTuple_CheckExact(operand1));
8875 CHECK_OBJECT(operand2);
8876 assert(PyTuple_CheckExact(operand2));
8878 PyTupleObject *a = (PyTupleObject *)operand1;
8879 PyTupleObject *b = (PyTupleObject *)operand2;
8881 Py_ssize_t len_a = Py_SIZE(a);
8882 Py_ssize_t len_b = Py_SIZE(b);
8885 nuitka_bool res = NUITKA_BOOL_TRUE;
8888 for (i = 0; i < len_a && i < len_b; i++) {
8889 PyObject *aa = a->ob_item[i];
8890 PyObject *bb = b->ob_item[i];
8896 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
8898 if (res == NUITKA_BOOL_EXCEPTION) {
8902 if (res == NUITKA_BOOL_FALSE) {
8908 if (found ==
false) {
8909 bool r = len_a <= len_b;
8912 PyObject *result = BOOL_FROM(r);
8913 Py_INCREF_IMMORTAL(result);
8917 return RICH_COMPARE_LE_OBJECT_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
8920PyObject *RICH_COMPARE_LE_OBJECT_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
8922 if (Py_TYPE(operand1) == &PyTuple_Type) {
8923 return COMPARE_LE_OBJECT_TUPLE_TUPLE(operand1, operand2);
8926#if PYTHON_VERSION < 0x300
8927 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8931 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8936 PyTypeObject *type1 = Py_TYPE(operand1);
8938#if PYTHON_VERSION < 0x300
8940 if (type1 == &PyTuple_Type && !0) {
8942 richcmpfunc frich = PyTuple_Type.tp_richcompare;
8944 if (frich != NULL) {
8945 PyObject *result = (*frich)(operand1, operand2, Py_LE);
8947 if (result != Py_NotImplemented) {
8948 Py_LeaveRecursiveCall();
8953 Py_DECREF_IMMORTAL(result);
8957 cmpfunc fcmp = NULL;
8960 int c = (*fcmp)(operand1, operand2);
8961 c = adjust_tp_compare(c);
8963 Py_LeaveRecursiveCall();
8989 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8993 PyObject *result = BOOL_FROM(r);
8994 Py_INCREF_IMMORTAL(result);
9002 if (type1 != &PyTuple_Type && 0) {
9003 f = PyTuple_Type.tp_richcompare;
9006 PyObject *result = (*f)(operand2, operand1, Py_GE);
9008 if (result != Py_NotImplemented) {
9009 Py_LeaveRecursiveCall();
9014 Py_DECREF_IMMORTAL(result);
9018 f = TP_RICHCOMPARE(type1);
9020 PyObject *result = (*f)(operand1, operand2, Py_LE);
9022 if (result != Py_NotImplemented) {
9023 Py_LeaveRecursiveCall();
9028 Py_DECREF_IMMORTAL(result);
9031 f = PyTuple_Type.tp_richcompare;
9033 PyObject *result = (*f)(operand2, operand1, Py_GE);
9035 if (result != Py_NotImplemented) {
9036 Py_LeaveRecursiveCall();
9041 Py_DECREF_IMMORTAL(result);
9046 if (PyInstance_Check(operand1)) {
9047 cmpfunc fcmp = type1->tp_compare;
9048 c = (*fcmp)(operand1, operand2);
9050 cmpfunc fcmp = NULL;
9051 c = (*fcmp)(operand1, operand2);
9053 c = try_3way_compare(operand1, operand2);
9057 if (type1 == &PyTuple_Type) {
9058 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9059 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9061 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9062 }
else if (operand1 == Py_None) {
9065 }
else if (operand2 == Py_None) {
9068 }
else if (PyNumber_Check(operand1)) {
9071 if (PyNumber_Check(operand2)) {
9073 Py_uintptr_t aa = (Py_uintptr_t)type1;
9074 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9076 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9080 }
else if (PyNumber_Check(operand2)) {
9084 int s = strcmp(type1->tp_name,
"tuple");
9092 Py_uintptr_t aa = (Py_uintptr_t)type1;
9093 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9095 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9100 Py_LeaveRecursiveCall();
9102 if (unlikely(c <= -2)) {
9128 PyObject *result = BOOL_FROM(r);
9129 Py_INCREF_IMMORTAL(result);
9132 bool checked_reverse_op =
false;
9135 if (type1 != &PyTuple_Type && Nuitka_Type_IsSubtype(&PyTuple_Type, type1)) {
9136 f = PyTuple_Type.tp_richcompare;
9139 checked_reverse_op =
true;
9141 PyObject *result = (*f)(operand2, operand1, Py_GE);
9143 if (result != Py_NotImplemented) {
9144 Py_LeaveRecursiveCall();
9149 Py_DECREF_IMMORTAL(result);
9153 f = TP_RICHCOMPARE(type1);
9156 PyObject *result = (*f)(operand1, operand2, Py_LE);
9158 if (result != Py_NotImplemented) {
9159 Py_LeaveRecursiveCall();
9164 Py_DECREF_IMMORTAL(result);
9167 if (checked_reverse_op ==
false) {
9168 f = PyTuple_Type.tp_richcompare;
9171 PyObject *result = (*f)(operand2, operand1, Py_GE);
9173 if (result != Py_NotImplemented) {
9174 Py_LeaveRecursiveCall();
9179 Py_DECREF_IMMORTAL(result);
9183 Py_LeaveRecursiveCall();
9189 bool r = operand1 == operand2;
9190 PyObject *result = BOOL_FROM(r);
9191 Py_INCREF_IMMORTAL(result);
9195 bool r = operand1 != operand2;
9196 PyObject *result = BOOL_FROM(r);
9197 Py_INCREF_IMMORTAL(result);
9201#if PYTHON_VERSION < 0x360
9202 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= tuple()", type1->tp_name);
9204 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'tuple'", type1->tp_name);
9212PyObject *RICH_COMPARE_LE_OBJECT_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
9214 if (&PyTuple_Type == Py_TYPE(operand2)) {
9215 return COMPARE_LE_OBJECT_TUPLE_TUPLE(operand1, operand2);
9218#if PYTHON_VERSION < 0x300
9219 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9223 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9228 PyTypeObject *type2 = Py_TYPE(operand2);
9230#if PYTHON_VERSION < 0x300
9232 if (&PyTuple_Type == type2 && !0) {
9234 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9236 if (frich != NULL) {
9237 PyObject *result = (*frich)(operand1, operand2, Py_LE);
9239 if (result != Py_NotImplemented) {
9240 Py_LeaveRecursiveCall();
9245 Py_DECREF_IMMORTAL(result);
9249 cmpfunc fcmp = NULL;
9252 int c = (*fcmp)(operand1, operand2);
9253 c = adjust_tp_compare(c);
9255 Py_LeaveRecursiveCall();
9281 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9285 PyObject *result = BOOL_FROM(r);
9286 Py_INCREF_IMMORTAL(result);
9294 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9295 f = TP_RICHCOMPARE(type2);
9298 PyObject *result = (*f)(operand2, operand1, Py_GE);
9300 if (result != Py_NotImplemented) {
9301 Py_LeaveRecursiveCall();
9306 Py_DECREF_IMMORTAL(result);
9310 f = PyTuple_Type.tp_richcompare;
9312 PyObject *result = (*f)(operand1, operand2, Py_LE);
9314 if (result != Py_NotImplemented) {
9315 Py_LeaveRecursiveCall();
9320 Py_DECREF_IMMORTAL(result);
9323 f = TP_RICHCOMPARE(type2);
9325 PyObject *result = (*f)(operand2, operand1, Py_GE);
9327 if (result != Py_NotImplemented) {
9328 Py_LeaveRecursiveCall();
9333 Py_DECREF_IMMORTAL(result);
9339 cmpfunc fcmp = NULL;
9340 c = (*fcmp)(operand1, operand2);
9341 }
else if (PyInstance_Check(operand2)) {
9342 cmpfunc fcmp = type2->tp_compare;
9343 c = (*fcmp)(operand1, operand2);
9345 c = try_3way_compare(operand1, operand2);
9349 if (&PyTuple_Type == type2) {
9350 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9351 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9353 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9354 }
else if (operand1 == Py_None) {
9357 }
else if (operand2 == Py_None) {
9360 }
else if (PyNumber_Check(operand1)) {
9363 if (PyNumber_Check(operand2)) {
9365 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
9366 Py_uintptr_t bb = (Py_uintptr_t)type2;
9368 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9372 }
else if (PyNumber_Check(operand2)) {
9376 int s = strcmp(
"tuple", type2->tp_name);
9384 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
9385 Py_uintptr_t bb = (Py_uintptr_t)type2;
9387 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9392 Py_LeaveRecursiveCall();
9394 if (unlikely(c <= -2)) {
9420 PyObject *result = BOOL_FROM(r);
9421 Py_INCREF_IMMORTAL(result);
9424 bool checked_reverse_op =
false;
9427 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9428 f = TP_RICHCOMPARE(type2);
9431 checked_reverse_op =
true;
9433 PyObject *result = (*f)(operand2, operand1, Py_GE);
9435 if (result != Py_NotImplemented) {
9436 Py_LeaveRecursiveCall();
9441 Py_DECREF_IMMORTAL(result);
9445 f = PyTuple_Type.tp_richcompare;
9448 PyObject *result = (*f)(operand1, operand2, Py_LE);
9450 if (result != Py_NotImplemented) {
9451 Py_LeaveRecursiveCall();
9456 Py_DECREF_IMMORTAL(result);
9459 if (checked_reverse_op ==
false) {
9460 f = TP_RICHCOMPARE(type2);
9463 PyObject *result = (*f)(operand2, operand1, Py_GE);
9465 if (result != Py_NotImplemented) {
9466 Py_LeaveRecursiveCall();
9471 Py_DECREF_IMMORTAL(result);
9475 Py_LeaveRecursiveCall();
9481 bool r = operand1 == operand2;
9482 PyObject *result = BOOL_FROM(r);
9483 Py_INCREF_IMMORTAL(result);
9487 bool r = operand1 != operand2;
9488 PyObject *result = BOOL_FROM(r);
9489 Py_INCREF_IMMORTAL(result);
9493#if PYTHON_VERSION < 0x360
9494 PyErr_Format(PyExc_TypeError,
"unorderable types: tuple() <= %s()", type2->tp_name);
9496 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'tuple' and '%s'", type2->tp_name);
9504PyObject *RICH_COMPARE_LE_OBJECT_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
9506 return COMPARE_LE_OBJECT_TUPLE_TUPLE(operand1, operand2);
9509static nuitka_bool COMPARE_LE_NBOOL_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
9510 CHECK_OBJECT(operand1);
9511 assert(PyTuple_CheckExact(operand1));
9512 CHECK_OBJECT(operand2);
9513 assert(PyTuple_CheckExact(operand2));
9515 PyTupleObject *a = (PyTupleObject *)operand1;
9516 PyTupleObject *b = (PyTupleObject *)operand2;
9518 Py_ssize_t len_a = Py_SIZE(a);
9519 Py_ssize_t len_b = Py_SIZE(b);
9522 nuitka_bool res = NUITKA_BOOL_TRUE;
9525 for (i = 0; i < len_a && i < len_b; i++) {
9526 PyObject *aa = a->ob_item[i];
9527 PyObject *bb = b->ob_item[i];
9533 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
9535 if (res == NUITKA_BOOL_EXCEPTION) {
9536 return NUITKA_BOOL_EXCEPTION;
9539 if (res == NUITKA_BOOL_FALSE) {
9545 if (found ==
false) {
9546 bool r = len_a <= len_b;
9549 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9554 return RICH_COMPARE_LE_NBOOL_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
9557nuitka_bool RICH_COMPARE_LE_NBOOL_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
9559 if (Py_TYPE(operand1) == &PyTuple_Type) {
9560 return COMPARE_LE_NBOOL_TUPLE_TUPLE(operand1, operand2);
9563#if PYTHON_VERSION < 0x300
9564 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9565 return NUITKA_BOOL_EXCEPTION;
9568 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9569 return NUITKA_BOOL_EXCEPTION;
9573 PyTypeObject *type1 = Py_TYPE(operand1);
9575#if PYTHON_VERSION < 0x300
9577 if (type1 == &PyTuple_Type && !0) {
9579 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9581 if (frich != NULL) {
9582 PyObject *result = (*frich)(operand1, operand2, Py_LE);
9584 if (result != Py_NotImplemented) {
9585 Py_LeaveRecursiveCall();
9587 if (unlikely(result == NULL)) {
9588 return NUITKA_BOOL_EXCEPTION;
9592 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9598 Py_DECREF_IMMORTAL(result);
9602 cmpfunc fcmp = NULL;
9605 int c = (*fcmp)(operand1, operand2);
9606 c = adjust_tp_compare(c);
9608 Py_LeaveRecursiveCall();
9611 return NUITKA_BOOL_EXCEPTION;
9634 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9638 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9647 if (type1 != &PyTuple_Type && 0) {
9648 f = PyTuple_Type.tp_richcompare;
9651 PyObject *result = (*f)(operand2, operand1, Py_GE);
9653 if (result != Py_NotImplemented) {
9654 Py_LeaveRecursiveCall();
9656 if (unlikely(result == NULL)) {
9657 return NUITKA_BOOL_EXCEPTION;
9661 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9667 Py_DECREF_IMMORTAL(result);
9671 f = TP_RICHCOMPARE(type1);
9673 PyObject *result = (*f)(operand1, operand2, Py_LE);
9675 if (result != Py_NotImplemented) {
9676 Py_LeaveRecursiveCall();
9678 if (unlikely(result == NULL)) {
9679 return NUITKA_BOOL_EXCEPTION;
9683 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9689 Py_DECREF_IMMORTAL(result);
9692 f = PyTuple_Type.tp_richcompare;
9694 PyObject *result = (*f)(operand2, operand1, Py_GE);
9696 if (result != Py_NotImplemented) {
9697 Py_LeaveRecursiveCall();
9699 if (unlikely(result == NULL)) {
9700 return NUITKA_BOOL_EXCEPTION;
9704 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9710 Py_DECREF_IMMORTAL(result);
9715 if (PyInstance_Check(operand1)) {
9716 cmpfunc fcmp = type1->tp_compare;
9717 c = (*fcmp)(operand1, operand2);
9719 cmpfunc fcmp = NULL;
9720 c = (*fcmp)(operand1, operand2);
9722 c = try_3way_compare(operand1, operand2);
9726 if (type1 == &PyTuple_Type) {
9727 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9728 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9730 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9731 }
else if (operand1 == Py_None) {
9734 }
else if (operand2 == Py_None) {
9737 }
else if (PyNumber_Check(operand1)) {
9740 if (PyNumber_Check(operand2)) {
9742 Py_uintptr_t aa = (Py_uintptr_t)type1;
9743 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9745 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9749 }
else if (PyNumber_Check(operand2)) {
9753 int s = strcmp(type1->tp_name,
"tuple");
9761 Py_uintptr_t aa = (Py_uintptr_t)type1;
9762 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9764 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9769 Py_LeaveRecursiveCall();
9771 if (unlikely(c <= -2)) {
9772 return NUITKA_BOOL_EXCEPTION;
9797 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9801 bool checked_reverse_op =
false;
9804 if (type1 != &PyTuple_Type && Nuitka_Type_IsSubtype(&PyTuple_Type, type1)) {
9805 f = PyTuple_Type.tp_richcompare;
9808 checked_reverse_op =
true;
9810 PyObject *result = (*f)(operand2, operand1, Py_GE);
9812 if (result != Py_NotImplemented) {
9813 Py_LeaveRecursiveCall();
9815 if (unlikely(result == NULL)) {
9816 return NUITKA_BOOL_EXCEPTION;
9820 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9826 Py_DECREF_IMMORTAL(result);
9830 f = TP_RICHCOMPARE(type1);
9833 PyObject *result = (*f)(operand1, operand2, Py_LE);
9835 if (result != Py_NotImplemented) {
9836 Py_LeaveRecursiveCall();
9838 if (unlikely(result == NULL)) {
9839 return NUITKA_BOOL_EXCEPTION;
9843 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9849 Py_DECREF_IMMORTAL(result);
9852 if (checked_reverse_op ==
false) {
9853 f = PyTuple_Type.tp_richcompare;
9856 PyObject *result = (*f)(operand2, operand1, Py_GE);
9858 if (result != Py_NotImplemented) {
9859 Py_LeaveRecursiveCall();
9861 if (unlikely(result == NULL)) {
9862 return NUITKA_BOOL_EXCEPTION;
9866 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9872 Py_DECREF_IMMORTAL(result);
9876 Py_LeaveRecursiveCall();
9882 bool r = operand1 == operand2;
9883 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9888 bool r = operand1 != operand2;
9889 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9894#if PYTHON_VERSION < 0x360
9895 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= tuple()", type1->tp_name);
9897 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'tuple'", type1->tp_name);
9899 return NUITKA_BOOL_EXCEPTION;
9905nuitka_bool RICH_COMPARE_LE_NBOOL_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
9907 if (&PyTuple_Type == Py_TYPE(operand2)) {
9908 return COMPARE_LE_NBOOL_TUPLE_TUPLE(operand1, operand2);
9911#if PYTHON_VERSION < 0x300
9912 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9913 return NUITKA_BOOL_EXCEPTION;
9916 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9917 return NUITKA_BOOL_EXCEPTION;
9921 PyTypeObject *type2 = Py_TYPE(operand2);
9923#if PYTHON_VERSION < 0x300
9925 if (&PyTuple_Type == type2 && !0) {
9927 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9929 if (frich != NULL) {
9930 PyObject *result = (*frich)(operand1, operand2, Py_LE);
9932 if (result != Py_NotImplemented) {
9933 Py_LeaveRecursiveCall();
9935 if (unlikely(result == NULL)) {
9936 return NUITKA_BOOL_EXCEPTION;
9940 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9946 Py_DECREF_IMMORTAL(result);
9950 cmpfunc fcmp = NULL;
9953 int c = (*fcmp)(operand1, operand2);
9954 c = adjust_tp_compare(c);
9956 Py_LeaveRecursiveCall();
9959 return NUITKA_BOOL_EXCEPTION;
9982 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9986 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9995 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9996 f = TP_RICHCOMPARE(type2);
9999 PyObject *result = (*f)(operand2, operand1, Py_GE);
10001 if (result != Py_NotImplemented) {
10002 Py_LeaveRecursiveCall();
10004 if (unlikely(result == NULL)) {
10005 return NUITKA_BOOL_EXCEPTION;
10009 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10015 Py_DECREF_IMMORTAL(result);
10019 f = PyTuple_Type.tp_richcompare;
10021 PyObject *result = (*f)(operand1, operand2, Py_LE);
10023 if (result != Py_NotImplemented) {
10024 Py_LeaveRecursiveCall();
10026 if (unlikely(result == NULL)) {
10027 return NUITKA_BOOL_EXCEPTION;
10031 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10037 Py_DECREF_IMMORTAL(result);
10040 f = TP_RICHCOMPARE(type2);
10042 PyObject *result = (*f)(operand2, operand1, Py_GE);
10044 if (result != Py_NotImplemented) {
10045 Py_LeaveRecursiveCall();
10047 if (unlikely(result == NULL)) {
10048 return NUITKA_BOOL_EXCEPTION;
10052 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10058 Py_DECREF_IMMORTAL(result);
10064 cmpfunc fcmp = NULL;
10065 c = (*fcmp)(operand1, operand2);
10066 }
else if (PyInstance_Check(operand2)) {
10067 cmpfunc fcmp = type2->tp_compare;
10068 c = (*fcmp)(operand1, operand2);
10070 c = try_3way_compare(operand1, operand2);
10074 if (&PyTuple_Type == type2) {
10075 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10076 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10078 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10079 }
else if (operand1 == Py_None) {
10082 }
else if (operand2 == Py_None) {
10085 }
else if (PyNumber_Check(operand1)) {
10088 if (PyNumber_Check(operand2)) {
10090 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
10091 Py_uintptr_t bb = (Py_uintptr_t)type2;
10093 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10097 }
else if (PyNumber_Check(operand2)) {
10101 int s = strcmp(
"tuple", type2->tp_name);
10105 }
else if (s > 0) {
10109 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
10110 Py_uintptr_t bb = (Py_uintptr_t)type2;
10112 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10117 Py_LeaveRecursiveCall();
10119 if (unlikely(c <= -2)) {
10120 return NUITKA_BOOL_EXCEPTION;
10145 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10149 bool checked_reverse_op =
false;
10152 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
10153 f = TP_RICHCOMPARE(type2);
10156 checked_reverse_op =
true;
10158 PyObject *result = (*f)(operand2, operand1, Py_GE);
10160 if (result != Py_NotImplemented) {
10161 Py_LeaveRecursiveCall();
10163 if (unlikely(result == NULL)) {
10164 return NUITKA_BOOL_EXCEPTION;
10168 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10174 Py_DECREF_IMMORTAL(result);
10178 f = PyTuple_Type.tp_richcompare;
10181 PyObject *result = (*f)(operand1, operand2, Py_LE);
10183 if (result != Py_NotImplemented) {
10184 Py_LeaveRecursiveCall();
10186 if (unlikely(result == NULL)) {
10187 return NUITKA_BOOL_EXCEPTION;
10191 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10197 Py_DECREF_IMMORTAL(result);
10200 if (checked_reverse_op ==
false) {
10201 f = TP_RICHCOMPARE(type2);
10204 PyObject *result = (*f)(operand2, operand1, Py_GE);
10206 if (result != Py_NotImplemented) {
10207 Py_LeaveRecursiveCall();
10209 if (unlikely(result == NULL)) {
10210 return NUITKA_BOOL_EXCEPTION;
10214 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10220 Py_DECREF_IMMORTAL(result);
10224 Py_LeaveRecursiveCall();
10230 bool r = operand1 == operand2;
10231 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10236 bool r = operand1 != operand2;
10237 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10242#if PYTHON_VERSION < 0x360
10243 PyErr_Format(PyExc_TypeError,
"unorderable types: tuple() <= %s()", type2->tp_name);
10245 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'tuple' and '%s'", type2->tp_name);
10247 return NUITKA_BOOL_EXCEPTION;
10253nuitka_bool RICH_COMPARE_LE_NBOOL_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
10255 return COMPARE_LE_NBOOL_TUPLE_TUPLE(operand1, operand2);
10258static PyObject *COMPARE_LE_OBJECT_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10259 CHECK_OBJECT(operand1);
10260 assert(PyList_CheckExact(operand1));
10261 CHECK_OBJECT(operand2);
10262 assert(PyList_CheckExact(operand2));
10264 PyListObject *a = (PyListObject *)operand1;
10265 PyListObject *b = (PyListObject *)operand2;
10267 bool found =
false;
10268 nuitka_bool res = NUITKA_BOOL_TRUE;
10271 for (i = 0; i < Py_SIZE(a) && i < Py_SIZE(b); i++) {
10272 PyObject *aa = a->ob_item[i];
10273 PyObject *bb = b->ob_item[i];
10281 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
10285 if (res == NUITKA_BOOL_EXCEPTION) {
10289 if (res == NUITKA_BOOL_FALSE) {
10295 if (found ==
false) {
10296 bool r = Py_SIZE(a) <= Py_SIZE(b);
10299 PyObject *result = BOOL_FROM(r);
10300 Py_INCREF_IMMORTAL(result);
10304 return RICH_COMPARE_LE_OBJECT_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
10307PyObject *RICH_COMPARE_LE_OBJECT_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
10309 if (Py_TYPE(operand1) == &PyList_Type) {
10310 return COMPARE_LE_OBJECT_LIST_LIST(operand1, operand2);
10313#if PYTHON_VERSION < 0x300
10314 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10318 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10323 PyTypeObject *type1 = Py_TYPE(operand1);
10325#if PYTHON_VERSION < 0x300
10327 if (type1 == &PyList_Type && !0) {
10329 richcmpfunc frich = PyList_Type.tp_richcompare;
10331 if (frich != NULL) {
10332 PyObject *result = (*frich)(operand1, operand2, Py_LE);
10334 if (result != Py_NotImplemented) {
10335 Py_LeaveRecursiveCall();
10340 Py_DECREF_IMMORTAL(result);
10344 cmpfunc fcmp = NULL;
10346 if (fcmp != NULL) {
10347 int c = (*fcmp)(operand1, operand2);
10348 c = adjust_tp_compare(c);
10350 Py_LeaveRecursiveCall();
10376 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10380 PyObject *result = BOOL_FROM(r);
10381 Py_INCREF_IMMORTAL(result);
10389 if (type1 != &PyList_Type && 0) {
10390 f = PyList_Type.tp_richcompare;
10393 PyObject *result = (*f)(operand2, operand1, Py_GE);
10395 if (result != Py_NotImplemented) {
10396 Py_LeaveRecursiveCall();
10401 Py_DECREF_IMMORTAL(result);
10405 f = TP_RICHCOMPARE(type1);
10407 PyObject *result = (*f)(operand1, operand2, Py_LE);
10409 if (result != Py_NotImplemented) {
10410 Py_LeaveRecursiveCall();
10415 Py_DECREF_IMMORTAL(result);
10418 f = PyList_Type.tp_richcompare;
10420 PyObject *result = (*f)(operand2, operand1, Py_GE);
10422 if (result != Py_NotImplemented) {
10423 Py_LeaveRecursiveCall();
10428 Py_DECREF_IMMORTAL(result);
10433 if (PyInstance_Check(operand1)) {
10434 cmpfunc fcmp = type1->tp_compare;
10435 c = (*fcmp)(operand1, operand2);
10437 cmpfunc fcmp = NULL;
10438 c = (*fcmp)(operand1, operand2);
10440 c = try_3way_compare(operand1, operand2);
10444 if (type1 == &PyList_Type) {
10445 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10446 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10448 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10449 }
else if (operand1 == Py_None) {
10452 }
else if (operand2 == Py_None) {
10455 }
else if (PyNumber_Check(operand1)) {
10458 if (PyNumber_Check(operand2)) {
10460 Py_uintptr_t aa = (Py_uintptr_t)type1;
10461 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
10463 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10467 }
else if (PyNumber_Check(operand2)) {
10471 int s = strcmp(type1->tp_name,
"list");
10475 }
else if (s > 0) {
10479 Py_uintptr_t aa = (Py_uintptr_t)type1;
10480 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
10482 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10487 Py_LeaveRecursiveCall();
10489 if (unlikely(c <= -2)) {
10515 PyObject *result = BOOL_FROM(r);
10516 Py_INCREF_IMMORTAL(result);
10519 bool checked_reverse_op =
false;
10522 if (type1 != &PyList_Type && Nuitka_Type_IsSubtype(&PyList_Type, type1)) {
10523 f = PyList_Type.tp_richcompare;
10526 checked_reverse_op =
true;
10528 PyObject *result = (*f)(operand2, operand1, Py_GE);
10530 if (result != Py_NotImplemented) {
10531 Py_LeaveRecursiveCall();
10536 Py_DECREF_IMMORTAL(result);
10540 f = TP_RICHCOMPARE(type1);
10543 PyObject *result = (*f)(operand1, operand2, Py_LE);
10545 if (result != Py_NotImplemented) {
10546 Py_LeaveRecursiveCall();
10551 Py_DECREF_IMMORTAL(result);
10554 if (checked_reverse_op ==
false) {
10555 f = PyList_Type.tp_richcompare;
10558 PyObject *result = (*f)(operand2, operand1, Py_GE);
10560 if (result != Py_NotImplemented) {
10561 Py_LeaveRecursiveCall();
10566 Py_DECREF_IMMORTAL(result);
10570 Py_LeaveRecursiveCall();
10576 bool r = operand1 == operand2;
10577 PyObject *result = BOOL_FROM(r);
10578 Py_INCREF_IMMORTAL(result);
10582 bool r = operand1 != operand2;
10583 PyObject *result = BOOL_FROM(r);
10584 Py_INCREF_IMMORTAL(result);
10588#if PYTHON_VERSION < 0x360
10589 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= list()", type1->tp_name);
10591 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'list'", type1->tp_name);
10599PyObject *RICH_COMPARE_LE_OBJECT_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
10601 if (&PyList_Type == Py_TYPE(operand2)) {
10602 return COMPARE_LE_OBJECT_LIST_LIST(operand1, operand2);
10605#if PYTHON_VERSION < 0x300
10606 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10610 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10615 PyTypeObject *type2 = Py_TYPE(operand2);
10617#if PYTHON_VERSION < 0x300
10619 if (&PyList_Type == type2 && !0) {
10621 richcmpfunc frich = PyList_Type.tp_richcompare;
10623 if (frich != NULL) {
10624 PyObject *result = (*frich)(operand1, operand2, Py_LE);
10626 if (result != Py_NotImplemented) {
10627 Py_LeaveRecursiveCall();
10632 Py_DECREF_IMMORTAL(result);
10636 cmpfunc fcmp = NULL;
10638 if (fcmp != NULL) {
10639 int c = (*fcmp)(operand1, operand2);
10640 c = adjust_tp_compare(c);
10642 Py_LeaveRecursiveCall();
10668 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10672 PyObject *result = BOOL_FROM(r);
10673 Py_INCREF_IMMORTAL(result);
10681 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
10682 f = TP_RICHCOMPARE(type2);
10685 PyObject *result = (*f)(operand2, operand1, Py_GE);
10687 if (result != Py_NotImplemented) {
10688 Py_LeaveRecursiveCall();
10693 Py_DECREF_IMMORTAL(result);
10697 f = PyList_Type.tp_richcompare;
10699 PyObject *result = (*f)(operand1, operand2, Py_LE);
10701 if (result != Py_NotImplemented) {
10702 Py_LeaveRecursiveCall();
10707 Py_DECREF_IMMORTAL(result);
10710 f = TP_RICHCOMPARE(type2);
10712 PyObject *result = (*f)(operand2, operand1, Py_GE);
10714 if (result != Py_NotImplemented) {
10715 Py_LeaveRecursiveCall();
10720 Py_DECREF_IMMORTAL(result);
10726 cmpfunc fcmp = NULL;
10727 c = (*fcmp)(operand1, operand2);
10728 }
else if (PyInstance_Check(operand2)) {
10729 cmpfunc fcmp = type2->tp_compare;
10730 c = (*fcmp)(operand1, operand2);
10732 c = try_3way_compare(operand1, operand2);
10736 if (&PyList_Type == type2) {
10737 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10738 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10740 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10741 }
else if (operand1 == Py_None) {
10744 }
else if (operand2 == Py_None) {
10747 }
else if (PyNumber_Check(operand1)) {
10750 if (PyNumber_Check(operand2)) {
10752 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
10753 Py_uintptr_t bb = (Py_uintptr_t)type2;
10755 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10759 }
else if (PyNumber_Check(operand2)) {
10763 int s = strcmp(
"list", type2->tp_name);
10767 }
else if (s > 0) {
10771 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
10772 Py_uintptr_t bb = (Py_uintptr_t)type2;
10774 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10779 Py_LeaveRecursiveCall();
10781 if (unlikely(c <= -2)) {
10807 PyObject *result = BOOL_FROM(r);
10808 Py_INCREF_IMMORTAL(result);
10811 bool checked_reverse_op =
false;
10814 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
10815 f = TP_RICHCOMPARE(type2);
10818 checked_reverse_op =
true;
10820 PyObject *result = (*f)(operand2, operand1, Py_GE);
10822 if (result != Py_NotImplemented) {
10823 Py_LeaveRecursiveCall();
10828 Py_DECREF_IMMORTAL(result);
10832 f = PyList_Type.tp_richcompare;
10835 PyObject *result = (*f)(operand1, operand2, Py_LE);
10837 if (result != Py_NotImplemented) {
10838 Py_LeaveRecursiveCall();
10843 Py_DECREF_IMMORTAL(result);
10846 if (checked_reverse_op ==
false) {
10847 f = TP_RICHCOMPARE(type2);
10850 PyObject *result = (*f)(operand2, operand1, Py_GE);
10852 if (result != Py_NotImplemented) {
10853 Py_LeaveRecursiveCall();
10858 Py_DECREF_IMMORTAL(result);
10862 Py_LeaveRecursiveCall();
10868 bool r = operand1 == operand2;
10869 PyObject *result = BOOL_FROM(r);
10870 Py_INCREF_IMMORTAL(result);
10874 bool r = operand1 != operand2;
10875 PyObject *result = BOOL_FROM(r);
10876 Py_INCREF_IMMORTAL(result);
10880#if PYTHON_VERSION < 0x360
10881 PyErr_Format(PyExc_TypeError,
"unorderable types: list() <= %s()", type2->tp_name);
10883 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'list' and '%s'", type2->tp_name);
10891PyObject *RICH_COMPARE_LE_OBJECT_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10893 return COMPARE_LE_OBJECT_LIST_LIST(operand1, operand2);
10896static nuitka_bool COMPARE_LE_NBOOL_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10897 CHECK_OBJECT(operand1);
10898 assert(PyList_CheckExact(operand1));
10899 CHECK_OBJECT(operand2);
10900 assert(PyList_CheckExact(operand2));
10902 PyListObject *a = (PyListObject *)operand1;
10903 PyListObject *b = (PyListObject *)operand2;
10905 bool found =
false;
10906 nuitka_bool res = NUITKA_BOOL_TRUE;
10909 for (i = 0; i < Py_SIZE(a) && i < Py_SIZE(b); i++) {
10910 PyObject *aa = a->ob_item[i];
10911 PyObject *bb = b->ob_item[i];
10919 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
10923 if (res == NUITKA_BOOL_EXCEPTION) {
10924 return NUITKA_BOOL_EXCEPTION;
10927 if (res == NUITKA_BOOL_FALSE) {
10933 if (found ==
false) {
10934 bool r = Py_SIZE(a) <= Py_SIZE(b);
10937 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10942 return RICH_COMPARE_LE_NBOOL_OBJECT_OBJECT(a->ob_item[i], b->ob_item[i]);
10945nuitka_bool RICH_COMPARE_LE_NBOOL_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
10947 if (Py_TYPE(operand1) == &PyList_Type) {
10948 return COMPARE_LE_NBOOL_LIST_LIST(operand1, operand2);
10951#if PYTHON_VERSION < 0x300
10952 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10953 return NUITKA_BOOL_EXCEPTION;
10956 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10957 return NUITKA_BOOL_EXCEPTION;
10961 PyTypeObject *type1 = Py_TYPE(operand1);
10963#if PYTHON_VERSION < 0x300
10965 if (type1 == &PyList_Type && !0) {
10967 richcmpfunc frich = PyList_Type.tp_richcompare;
10969 if (frich != NULL) {
10970 PyObject *result = (*frich)(operand1, operand2, Py_LE);
10972 if (result != Py_NotImplemented) {
10973 Py_LeaveRecursiveCall();
10975 if (unlikely(result == NULL)) {
10976 return NUITKA_BOOL_EXCEPTION;
10980 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10986 Py_DECREF_IMMORTAL(result);
10990 cmpfunc fcmp = NULL;
10992 if (fcmp != NULL) {
10993 int c = (*fcmp)(operand1, operand2);
10994 c = adjust_tp_compare(c);
10996 Py_LeaveRecursiveCall();
10999 return NUITKA_BOOL_EXCEPTION;
11022 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
11026 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11035 if (type1 != &PyList_Type && 0) {
11036 f = PyList_Type.tp_richcompare;
11039 PyObject *result = (*f)(operand2, operand1, Py_GE);
11041 if (result != Py_NotImplemented) {
11042 Py_LeaveRecursiveCall();
11044 if (unlikely(result == NULL)) {
11045 return NUITKA_BOOL_EXCEPTION;
11049 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11055 Py_DECREF_IMMORTAL(result);
11059 f = TP_RICHCOMPARE(type1);
11061 PyObject *result = (*f)(operand1, operand2, Py_LE);
11063 if (result != Py_NotImplemented) {
11064 Py_LeaveRecursiveCall();
11066 if (unlikely(result == NULL)) {
11067 return NUITKA_BOOL_EXCEPTION;
11071 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11077 Py_DECREF_IMMORTAL(result);
11080 f = PyList_Type.tp_richcompare;
11082 PyObject *result = (*f)(operand2, operand1, Py_GE);
11084 if (result != Py_NotImplemented) {
11085 Py_LeaveRecursiveCall();
11087 if (unlikely(result == NULL)) {
11088 return NUITKA_BOOL_EXCEPTION;
11092 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11098 Py_DECREF_IMMORTAL(result);
11103 if (PyInstance_Check(operand1)) {
11104 cmpfunc fcmp = type1->tp_compare;
11105 c = (*fcmp)(operand1, operand2);
11107 cmpfunc fcmp = NULL;
11108 c = (*fcmp)(operand1, operand2);
11110 c = try_3way_compare(operand1, operand2);
11114 if (type1 == &PyList_Type) {
11115 Py_uintptr_t aa = (Py_uintptr_t)operand1;
11116 Py_uintptr_t bb = (Py_uintptr_t)operand2;
11118 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11119 }
else if (operand1 == Py_None) {
11122 }
else if (operand2 == Py_None) {
11125 }
else if (PyNumber_Check(operand1)) {
11128 if (PyNumber_Check(operand2)) {
11130 Py_uintptr_t aa = (Py_uintptr_t)type1;
11131 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
11133 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11137 }
else if (PyNumber_Check(operand2)) {
11141 int s = strcmp(type1->tp_name,
"list");
11145 }
else if (s > 0) {
11149 Py_uintptr_t aa = (Py_uintptr_t)type1;
11150 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
11152 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11157 Py_LeaveRecursiveCall();
11159 if (unlikely(c <= -2)) {
11160 return NUITKA_BOOL_EXCEPTION;
11185 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11189 bool checked_reverse_op =
false;
11192 if (type1 != &PyList_Type && Nuitka_Type_IsSubtype(&PyList_Type, type1)) {
11193 f = PyList_Type.tp_richcompare;
11196 checked_reverse_op =
true;
11198 PyObject *result = (*f)(operand2, operand1, Py_GE);
11200 if (result != Py_NotImplemented) {
11201 Py_LeaveRecursiveCall();
11203 if (unlikely(result == NULL)) {
11204 return NUITKA_BOOL_EXCEPTION;
11208 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11214 Py_DECREF_IMMORTAL(result);
11218 f = TP_RICHCOMPARE(type1);
11221 PyObject *result = (*f)(operand1, operand2, Py_LE);
11223 if (result != Py_NotImplemented) {
11224 Py_LeaveRecursiveCall();
11226 if (unlikely(result == NULL)) {
11227 return NUITKA_BOOL_EXCEPTION;
11231 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11237 Py_DECREF_IMMORTAL(result);
11240 if (checked_reverse_op ==
false) {
11241 f = PyList_Type.tp_richcompare;
11244 PyObject *result = (*f)(operand2, operand1, Py_GE);
11246 if (result != Py_NotImplemented) {
11247 Py_LeaveRecursiveCall();
11249 if (unlikely(result == NULL)) {
11250 return NUITKA_BOOL_EXCEPTION;
11254 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11260 Py_DECREF_IMMORTAL(result);
11264 Py_LeaveRecursiveCall();
11270 bool r = operand1 == operand2;
11271 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11276 bool r = operand1 != operand2;
11277 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11282#if PYTHON_VERSION < 0x360
11283 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() <= list()", type1->tp_name);
11285 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of '%s' and 'list'", type1->tp_name);
11287 return NUITKA_BOOL_EXCEPTION;
11293nuitka_bool RICH_COMPARE_LE_NBOOL_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
11295 if (&PyList_Type == Py_TYPE(operand2)) {
11296 return COMPARE_LE_NBOOL_LIST_LIST(operand1, operand2);
11299#if PYTHON_VERSION < 0x300
11300 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
11301 return NUITKA_BOOL_EXCEPTION;
11304 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
11305 return NUITKA_BOOL_EXCEPTION;
11309 PyTypeObject *type2 = Py_TYPE(operand2);
11311#if PYTHON_VERSION < 0x300
11313 if (&PyList_Type == type2 && !0) {
11315 richcmpfunc frich = PyList_Type.tp_richcompare;
11317 if (frich != NULL) {
11318 PyObject *result = (*frich)(operand1, operand2, Py_LE);
11320 if (result != Py_NotImplemented) {
11321 Py_LeaveRecursiveCall();
11323 if (unlikely(result == NULL)) {
11324 return NUITKA_BOOL_EXCEPTION;
11328 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11334 Py_DECREF_IMMORTAL(result);
11338 cmpfunc fcmp = NULL;
11340 if (fcmp != NULL) {
11341 int c = (*fcmp)(operand1, operand2);
11342 c = adjust_tp_compare(c);
11344 Py_LeaveRecursiveCall();
11347 return NUITKA_BOOL_EXCEPTION;
11370 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
11374 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11383 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
11384 f = TP_RICHCOMPARE(type2);
11387 PyObject *result = (*f)(operand2, operand1, Py_GE);
11389 if (result != Py_NotImplemented) {
11390 Py_LeaveRecursiveCall();
11392 if (unlikely(result == NULL)) {
11393 return NUITKA_BOOL_EXCEPTION;
11397 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11403 Py_DECREF_IMMORTAL(result);
11407 f = PyList_Type.tp_richcompare;
11409 PyObject *result = (*f)(operand1, operand2, Py_LE);
11411 if (result != Py_NotImplemented) {
11412 Py_LeaveRecursiveCall();
11414 if (unlikely(result == NULL)) {
11415 return NUITKA_BOOL_EXCEPTION;
11419 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11425 Py_DECREF_IMMORTAL(result);
11428 f = TP_RICHCOMPARE(type2);
11430 PyObject *result = (*f)(operand2, operand1, Py_GE);
11432 if (result != Py_NotImplemented) {
11433 Py_LeaveRecursiveCall();
11435 if (unlikely(result == NULL)) {
11436 return NUITKA_BOOL_EXCEPTION;
11440 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11446 Py_DECREF_IMMORTAL(result);
11452 cmpfunc fcmp = NULL;
11453 c = (*fcmp)(operand1, operand2);
11454 }
else if (PyInstance_Check(operand2)) {
11455 cmpfunc fcmp = type2->tp_compare;
11456 c = (*fcmp)(operand1, operand2);
11458 c = try_3way_compare(operand1, operand2);
11462 if (&PyList_Type == type2) {
11463 Py_uintptr_t aa = (Py_uintptr_t)operand1;
11464 Py_uintptr_t bb = (Py_uintptr_t)operand2;
11466 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11467 }
else if (operand1 == Py_None) {
11470 }
else if (operand2 == Py_None) {
11473 }
else if (PyNumber_Check(operand1)) {
11476 if (PyNumber_Check(operand2)) {
11478 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
11479 Py_uintptr_t bb = (Py_uintptr_t)type2;
11481 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11485 }
else if (PyNumber_Check(operand2)) {
11489 int s = strcmp(
"list", type2->tp_name);
11493 }
else if (s > 0) {
11497 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
11498 Py_uintptr_t bb = (Py_uintptr_t)type2;
11500 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11505 Py_LeaveRecursiveCall();
11507 if (unlikely(c <= -2)) {
11508 return NUITKA_BOOL_EXCEPTION;
11533 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11537 bool checked_reverse_op =
false;
11540 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
11541 f = TP_RICHCOMPARE(type2);
11544 checked_reverse_op =
true;
11546 PyObject *result = (*f)(operand2, operand1, Py_GE);
11548 if (result != Py_NotImplemented) {
11549 Py_LeaveRecursiveCall();
11551 if (unlikely(result == NULL)) {
11552 return NUITKA_BOOL_EXCEPTION;
11556 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11562 Py_DECREF_IMMORTAL(result);
11566 f = PyList_Type.tp_richcompare;
11569 PyObject *result = (*f)(operand1, operand2, Py_LE);
11571 if (result != Py_NotImplemented) {
11572 Py_LeaveRecursiveCall();
11574 if (unlikely(result == NULL)) {
11575 return NUITKA_BOOL_EXCEPTION;
11579 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11585 Py_DECREF_IMMORTAL(result);
11588 if (checked_reverse_op ==
false) {
11589 f = TP_RICHCOMPARE(type2);
11592 PyObject *result = (*f)(operand2, operand1, Py_GE);
11594 if (result != Py_NotImplemented) {
11595 Py_LeaveRecursiveCall();
11597 if (unlikely(result == NULL)) {
11598 return NUITKA_BOOL_EXCEPTION;
11602 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11608 Py_DECREF_IMMORTAL(result);
11612 Py_LeaveRecursiveCall();
11618 bool r = operand1 == operand2;
11619 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11624 bool r = operand1 != operand2;
11625 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11630#if PYTHON_VERSION < 0x360
11631 PyErr_Format(PyExc_TypeError,
"unorderable types: list() <= %s()", type2->tp_name);
11633 PyErr_Format(PyExc_TypeError,
"'<=' not supported between instances of 'list' and '%s'", type2->tp_name);
11635 return NUITKA_BOOL_EXCEPTION;
11641nuitka_bool RICH_COMPARE_LE_NBOOL_LIST_LIST(PyObject *operand1, PyObject *operand2) {
11643 return COMPARE_LE_NBOOL_LIST_LIST(operand1, operand2);
11646static PyObject *COMPARE_LE_OBJECT_LONG_CLONG(PyObject *operand1,
long operand2) {
11647 CHECK_OBJECT(operand1);
11648 assert(PyLong_CheckExact(operand1));
11650 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11652 bool operand2_is_negative;
11653 unsigned long operand2_abs_ival;
11655 if (operand2 < 0) {
11656 operand2_abs_ival = (
unsigned long)(-1 - operand2) + 1;
11657 operand2_is_negative =
true;
11659 operand2_abs_ival = (
unsigned long)operand2;
11660 operand2_is_negative =
false;
11663 Py_ssize_t operand2_digit_count = 0;
11664 digit operand2_digits[5] = {0};
11666 unsigned long t = operand2_abs_ival;
11669 operand2_digit_count += 1;
11670 assert(operand2_digit_count <= (Py_ssize_t)(
sizeof(operand2_digit_count) /
sizeof(digit)));
11672 operand2_digits[operand2_digit_count] = (digit)(t & PyLong_MASK);
11673 t >>= PyLong_SHIFT;
11677 NUITKA_MAY_BE_UNUSED Py_ssize_t operand2_size =
11678 operand2_is_negative ==
false ? operand2_digit_count : -operand2_digit_count;
11682 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) != operand2_size) {
11683 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - operand2_size < 0;
11685 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11688 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != operand2_digits[i]) {
11689 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] < operand2_digits[i];
11690 if (Nuitka_LongIsNegative(operand1_long_object)) {
11699 PyObject *result = BOOL_FROM(r);
11700 Py_INCREF_IMMORTAL(result);
11703#if PYTHON_VERSION < 0x300
11705PyObject *RICH_COMPARE_LE_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
11707 return COMPARE_LE_OBJECT_LONG_CLONG(operand1, PyInt_AS_LONG(operand1));
11711static bool COMPARE_LE_CBOOL_LONG_CLONG(PyObject *operand1,
long operand2) {
11712 CHECK_OBJECT(operand1);
11713 assert(PyLong_CheckExact(operand1));
11715 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11717 bool operand2_is_negative;
11718 unsigned long operand2_abs_ival;
11720 if (operand2 < 0) {
11721 operand2_abs_ival = (
unsigned long)(-1 - operand2) + 1;
11722 operand2_is_negative =
true;
11724 operand2_abs_ival = (
unsigned long)operand2;
11725 operand2_is_negative =
false;
11728 Py_ssize_t operand2_digit_count = 0;
11729 digit operand2_digits[5] = {0};
11731 unsigned long t = operand2_abs_ival;
11734 operand2_digit_count += 1;
11735 assert(operand2_digit_count <= (Py_ssize_t)(
sizeof(operand2_digit_count) /
sizeof(digit)));
11737 operand2_digits[operand2_digit_count] = (digit)(t & PyLong_MASK);
11738 t >>= PyLong_SHIFT;
11742 NUITKA_MAY_BE_UNUSED Py_ssize_t operand2_size =
11743 operand2_is_negative ==
false ? operand2_digit_count : -operand2_digit_count;
11747 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) != operand2_size) {
11748 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) - operand2_size < 0;
11750 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11753 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != operand2_digits[i]) {
11754 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] < operand2_digits[i];
11755 if (Nuitka_LongIsNegative(operand1_long_object)) {
11768#if PYTHON_VERSION < 0x300
11770bool RICH_COMPARE_LE_CBOOL_LONG_INT(PyObject *operand1, PyObject *operand2) {
11772 return COMPARE_LE_CBOOL_LONG_CLONG(operand1, PyInt_AS_LONG(operand1));
11776#if PYTHON_VERSION < 0x300
11777static PyObject *COMPARE_LE_OBJECT_INT_CLONG(PyObject *operand1,
long operand2) {
11778 CHECK_OBJECT(operand1);
11779 assert(PyInt_CheckExact(operand1));
11781 const long a = PyInt_AS_LONG(operand1);
11782 const long b = operand2;
11787 PyObject *result = BOOL_FROM(r);
11788 Py_INCREF_IMMORTAL(result);
11792#if PYTHON_VERSION < 0x300
11794PyObject *RICH_COMPARE_LE_OBJECT_INT_CLONG(PyObject *operand1,
long operand2) {
11796 return COMPARE_LE_OBJECT_INT_CLONG(operand1, operand2);
11800#if PYTHON_VERSION < 0x300
11801static bool COMPARE_LE_CBOOL_INT_CLONG(PyObject *operand1,
long operand2) {
11802 CHECK_OBJECT(operand1);
11803 assert(PyInt_CheckExact(operand1));
11805 const long a = PyInt_AS_LONG(operand1);
11806 const long b = operand2;
11816#if PYTHON_VERSION < 0x300
11818bool RICH_COMPARE_LE_CBOOL_INT_CLONG(PyObject *operand1,
long operand2) {
11820 return COMPARE_LE_CBOOL_INT_CLONG(operand1, operand2);
11824static PyObject *COMPARE_LE_OBJECT_LONG_DIGIT(PyObject *operand1,
long operand2) {
11825 CHECK_OBJECT(operand1);
11826 assert(PyLong_CheckExact(operand1));
11827 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
11829 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11833 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
11834 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1))) {
11835 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) -
11836 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1)) <
11839 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11842 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != (digit)Py_ABS(operand2)) {
11843 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] < (digit)Py_ABS(operand2);
11844 if (Nuitka_LongIsNegative(operand1_long_object)) {
11853 PyObject *result = BOOL_FROM(r);
11854 Py_INCREF_IMMORTAL(result);
11859PyObject *RICH_COMPARE_LE_OBJECT_LONG_DIGIT(PyObject *operand1,
long operand2) {
11861 return COMPARE_LE_OBJECT_LONG_DIGIT(operand1, operand2);
11864static bool COMPARE_LE_CBOOL_LONG_DIGIT(PyObject *operand1,
long operand2) {
11865 CHECK_OBJECT(operand1);
11866 assert(PyLong_CheckExact(operand1));
11867 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
11869 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11873 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
11874 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1))) {
11875 r = Nuitka_LongGetSignedDigitSize(operand1_long_object) -
11876 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1)) <
11879 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11882 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != (digit)Py_ABS(operand2)) {
11883 r = Nuitka_LongGetDigitPointer(operand1_long_object)[i] < (digit)Py_ABS(operand2);
11884 if (Nuitka_LongIsNegative(operand1_long_object)) {
11899bool RICH_COMPARE_LE_CBOOL_LONG_DIGIT(PyObject *operand1,
long operand2) {
11901 return COMPARE_LE_CBOOL_LONG_DIGIT(operand1, operand2);
11904static PyObject *COMPARE_LE_OBJECT_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11905 CHECK_OBJECT(operand1);
11906 assert(PyFloat_CheckExact(operand1));
11908 const double a = PyFloat_AS_DOUBLE(operand1);
11909 const double b = operand2;
11914 PyObject *result = BOOL_FROM(r);
11915 Py_INCREF_IMMORTAL(result);
11919PyObject *RICH_COMPARE_LE_OBJECT_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11921 return COMPARE_LE_OBJECT_FLOAT_CFLOAT(operand1, operand2);
11924static bool COMPARE_LE_CBOOL_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11925 CHECK_OBJECT(operand1);
11926 assert(PyFloat_CheckExact(operand1));
11928 const double a = PyFloat_AS_DOUBLE(operand1);
11929 const double b = operand2;
11939bool RICH_COMPARE_LE_CBOOL_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
11941 return COMPARE_LE_CBOOL_FLOAT_CFLOAT(operand1, operand2);