7#include "nuitka/prelude.h"
10#include "HelpersComparisonEqUtils.c"
13#if PYTHON_VERSION < 0x300
14static PyObject *COMPARE_EQ_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
15 CHECK_OBJECT(operand1);
16 assert(PyInt_CheckExact(operand1));
17 CHECK_OBJECT(operand2);
18 assert(PyInt_CheckExact(operand2));
20 const long a = PyInt_AS_LONG(operand1);
21 const long b = PyInt_AS_LONG(operand2);
26 PyObject *result = BOOL_FROM(r);
27 Py_INCREF_IMMORTAL(result);
31#if PYTHON_VERSION < 0x300
32static bool COMPARE_EQ_CBOOL_INT_INT(PyObject *operand1, PyObject *operand2) {
33 CHECK_OBJECT(operand1);
34 assert(PyInt_CheckExact(operand1));
35 CHECK_OBJECT(operand2);
36 assert(PyInt_CheckExact(operand2));
38 const long a = PyInt_AS_LONG(operand1);
39 const long b = PyInt_AS_LONG(operand2);
50PyObject *RICH_COMPARE_EQ_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
52#if PYTHON_VERSION < 0x300
53 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
54 return COMPARE_EQ_OBJECT_INT_INT(operand1, operand2);
59 if (operand1 == operand2 && IS_SANE_TYPE(Py_TYPE(operand1))) {
61 PyObject *result = BOOL_FROM(r);
62 Py_INCREF_IMMORTAL(result);
66#if PYTHON_VERSION < 0x300
67 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
71 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
76 PyTypeObject *type1 = Py_TYPE(operand1);
77 PyTypeObject *type2 = Py_TYPE(operand2);
79#if PYTHON_VERSION < 0x300
81 if (type1 == type2 && !PyInstance_Check(operand1)) {
83 richcmpfunc frich = TP_RICHCOMPARE(type1);
86 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
88 if (result != Py_NotImplemented) {
89 Py_LeaveRecursiveCall();
94 Py_DECREF_IMMORTAL(result);
98 cmpfunc fcmp = type1->tp_compare;
101 int c = (*fcmp)(operand1, operand2);
102 c = adjust_tp_compare(c);
104 Py_LeaveRecursiveCall();
130 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
134 PyObject *result = BOOL_FROM(r);
135 Py_INCREF_IMMORTAL(result);
143 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
144 f = TP_RICHCOMPARE(type2);
147 PyObject *result = (*f)(operand2, operand1, Py_EQ);
149 if (result != Py_NotImplemented) {
150 Py_LeaveRecursiveCall();
155 Py_DECREF_IMMORTAL(result);
159 f = TP_RICHCOMPARE(type1);
161 PyObject *result = (*f)(operand1, operand2, Py_EQ);
163 if (result != Py_NotImplemented) {
164 Py_LeaveRecursiveCall();
169 Py_DECREF_IMMORTAL(result);
172 f = TP_RICHCOMPARE(type2);
174 PyObject *result = (*f)(operand2, operand1, Py_EQ);
176 if (result != Py_NotImplemented) {
177 Py_LeaveRecursiveCall();
182 Py_DECREF_IMMORTAL(result);
187 if (PyInstance_Check(operand1)) {
188 cmpfunc fcmp = type1->tp_compare;
189 c = (*fcmp)(operand1, operand2);
190 }
else if (PyInstance_Check(operand2)) {
191 cmpfunc fcmp = type2->tp_compare;
192 c = (*fcmp)(operand1, operand2);
194 c = try_3way_compare(operand1, operand2);
198 if (type1 == type2) {
199 Py_uintptr_t aa = (Py_uintptr_t)operand1;
200 Py_uintptr_t bb = (Py_uintptr_t)operand2;
202 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
203 }
else if (operand1 == Py_None) {
206 }
else if (operand2 == Py_None) {
209 }
else if (PyNumber_Check(operand1)) {
212 if (PyNumber_Check(operand2)) {
214 Py_uintptr_t aa = (Py_uintptr_t)type1;
215 Py_uintptr_t bb = (Py_uintptr_t)type2;
217 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
221 }
else if (PyNumber_Check(operand2)) {
225 int s = strcmp(type1->tp_name, type2->tp_name);
233 Py_uintptr_t aa = (Py_uintptr_t)type1;
234 Py_uintptr_t bb = (Py_uintptr_t)type2;
236 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
241 Py_LeaveRecursiveCall();
243 if (unlikely(c <= -2)) {
269 PyObject *result = BOOL_FROM(r);
270 Py_INCREF_IMMORTAL(result);
273 bool checked_reverse_op =
false;
276 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
277 f = TP_RICHCOMPARE(type2);
280 checked_reverse_op =
true;
282 PyObject *result = (*f)(operand2, operand1, Py_EQ);
284 if (result != Py_NotImplemented) {
285 Py_LeaveRecursiveCall();
290 Py_DECREF_IMMORTAL(result);
294 f = TP_RICHCOMPARE(type1);
297 PyObject *result = (*f)(operand1, operand2, Py_EQ);
299 if (result != Py_NotImplemented) {
300 Py_LeaveRecursiveCall();
305 Py_DECREF_IMMORTAL(result);
308 if (checked_reverse_op ==
false) {
309 f = TP_RICHCOMPARE(type2);
312 PyObject *result = (*f)(operand2, operand1, Py_EQ);
314 if (result != Py_NotImplemented) {
315 Py_LeaveRecursiveCall();
320 Py_DECREF_IMMORTAL(result);
324 Py_LeaveRecursiveCall();
330 bool r = operand1 == operand2;
331 PyObject *result = BOOL_FROM(r);
332 Py_INCREF_IMMORTAL(result);
336 bool r = operand1 != operand2;
337 PyObject *result = BOOL_FROM(r);
338 Py_INCREF_IMMORTAL(result);
342#if PYTHON_VERSION < 0x360
343 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == %s()", type1->tp_name, type2->tp_name);
345 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and '%s'", type1->tp_name,
354nuitka_bool RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
356#if PYTHON_VERSION < 0x300
357 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
358 return COMPARE_EQ_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
363 if (operand1 == operand2 && IS_SANE_TYPE(Py_TYPE(operand1))) {
365 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
370#if PYTHON_VERSION < 0x300
371 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
372 return NUITKA_BOOL_EXCEPTION;
375 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
376 return NUITKA_BOOL_EXCEPTION;
380 PyTypeObject *type1 = Py_TYPE(operand1);
381 PyTypeObject *type2 = Py_TYPE(operand2);
383#if PYTHON_VERSION < 0x300
385 if (type1 == type2 && !PyInstance_Check(operand1)) {
387 richcmpfunc frich = TP_RICHCOMPARE(type1);
390 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
392 if (result != Py_NotImplemented) {
393 Py_LeaveRecursiveCall();
395 if (unlikely(result == NULL)) {
396 return NUITKA_BOOL_EXCEPTION;
400 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
406 Py_DECREF_IMMORTAL(result);
410 cmpfunc fcmp = type1->tp_compare;
413 int c = (*fcmp)(operand1, operand2);
414 c = adjust_tp_compare(c);
416 Py_LeaveRecursiveCall();
419 return NUITKA_BOOL_EXCEPTION;
442 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
446 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
455 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
456 f = TP_RICHCOMPARE(type2);
459 PyObject *result = (*f)(operand2, operand1, Py_EQ);
461 if (result != Py_NotImplemented) {
462 Py_LeaveRecursiveCall();
464 if (unlikely(result == NULL)) {
465 return NUITKA_BOOL_EXCEPTION;
469 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
475 Py_DECREF_IMMORTAL(result);
479 f = TP_RICHCOMPARE(type1);
481 PyObject *result = (*f)(operand1, operand2, Py_EQ);
483 if (result != Py_NotImplemented) {
484 Py_LeaveRecursiveCall();
486 if (unlikely(result == NULL)) {
487 return NUITKA_BOOL_EXCEPTION;
491 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
497 Py_DECREF_IMMORTAL(result);
500 f = TP_RICHCOMPARE(type2);
502 PyObject *result = (*f)(operand2, operand1, Py_EQ);
504 if (result != Py_NotImplemented) {
505 Py_LeaveRecursiveCall();
507 if (unlikely(result == NULL)) {
508 return NUITKA_BOOL_EXCEPTION;
512 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
518 Py_DECREF_IMMORTAL(result);
523 if (PyInstance_Check(operand1)) {
524 cmpfunc fcmp = type1->tp_compare;
525 c = (*fcmp)(operand1, operand2);
526 }
else if (PyInstance_Check(operand2)) {
527 cmpfunc fcmp = type2->tp_compare;
528 c = (*fcmp)(operand1, operand2);
530 c = try_3way_compare(operand1, operand2);
534 if (type1 == type2) {
535 Py_uintptr_t aa = (Py_uintptr_t)operand1;
536 Py_uintptr_t bb = (Py_uintptr_t)operand2;
538 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
539 }
else if (operand1 == Py_None) {
542 }
else if (operand2 == Py_None) {
545 }
else if (PyNumber_Check(operand1)) {
548 if (PyNumber_Check(operand2)) {
550 Py_uintptr_t aa = (Py_uintptr_t)type1;
551 Py_uintptr_t bb = (Py_uintptr_t)type2;
553 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
557 }
else if (PyNumber_Check(operand2)) {
561 int s = strcmp(type1->tp_name, type2->tp_name);
569 Py_uintptr_t aa = (Py_uintptr_t)type1;
570 Py_uintptr_t bb = (Py_uintptr_t)type2;
572 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
577 Py_LeaveRecursiveCall();
579 if (unlikely(c <= -2)) {
580 return NUITKA_BOOL_EXCEPTION;
605 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
609 bool checked_reverse_op =
false;
612 if (type1 != type2 && Nuitka_Type_IsSubtype(type2, type1)) {
613 f = TP_RICHCOMPARE(type2);
616 checked_reverse_op =
true;
618 PyObject *result = (*f)(operand2, operand1, Py_EQ);
620 if (result != Py_NotImplemented) {
621 Py_LeaveRecursiveCall();
623 if (unlikely(result == NULL)) {
624 return NUITKA_BOOL_EXCEPTION;
628 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
634 Py_DECREF_IMMORTAL(result);
638 f = TP_RICHCOMPARE(type1);
641 PyObject *result = (*f)(operand1, operand2, Py_EQ);
643 if (result != Py_NotImplemented) {
644 Py_LeaveRecursiveCall();
646 if (unlikely(result == NULL)) {
647 return NUITKA_BOOL_EXCEPTION;
651 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
657 Py_DECREF_IMMORTAL(result);
660 if (checked_reverse_op ==
false) {
661 f = TP_RICHCOMPARE(type2);
664 PyObject *result = (*f)(operand2, operand1, Py_EQ);
666 if (result != Py_NotImplemented) {
667 Py_LeaveRecursiveCall();
669 if (unlikely(result == NULL)) {
670 return NUITKA_BOOL_EXCEPTION;
674 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
680 Py_DECREF_IMMORTAL(result);
684 Py_LeaveRecursiveCall();
690 bool r = operand1 == operand2;
691 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
696 bool r = operand1 != operand2;
697 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
702#if PYTHON_VERSION < 0x360
703 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == %s()", type1->tp_name, type2->tp_name);
705 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and '%s'", type1->tp_name,
708 return NUITKA_BOOL_EXCEPTION;
713#if PYTHON_VERSION < 0x300
714static PyObject *COMPARE_EQ_OBJECT_STR_STR(PyObject *operand1, PyObject *operand2) {
715 CHECK_OBJECT(operand1);
716 assert(PyString_CheckExact(operand1));
717 CHECK_OBJECT(operand2);
718 assert(PyString_CheckExact(operand2));
720 PyStringObject *a = (PyStringObject *)operand1;
721 PyStringObject *b = (PyStringObject *)operand2;
724 if (operand1 == operand2) {
728 PyObject *result = BOOL_FROM(r);
729 Py_INCREF_IMMORTAL(result);
733 Py_ssize_t len_a = Py_SIZE(operand1);
734 Py_ssize_t len_b = Py_SIZE(operand2);
736 if (len_a != len_b) {
740 PyObject *result = BOOL_FROM(r);
741 Py_INCREF_IMMORTAL(result);
744 if ((a->ob_sval[0] == b->ob_sval[0]) && (memcmp(a->ob_sval, b->ob_sval, len_a) == 0)) {
748 PyObject *result = BOOL_FROM(r);
749 Py_INCREF_IMMORTAL(result);
755 PyObject *result = BOOL_FROM(r);
756 Py_INCREF_IMMORTAL(result);
762#if PYTHON_VERSION < 0x300
764PyObject *RICH_COMPARE_EQ_OBJECT_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
766 if (Py_TYPE(operand1) == &PyString_Type) {
767 return COMPARE_EQ_OBJECT_STR_STR(operand1, operand2);
770#if PYTHON_VERSION < 0x300
771 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
775 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
780 PyTypeObject *type1 = Py_TYPE(operand1);
782#if PYTHON_VERSION < 0x300
784 if (type1 == &PyString_Type && !0) {
786 richcmpfunc frich = PyString_Type.tp_richcompare;
789 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
791 if (result != Py_NotImplemented) {
792 Py_LeaveRecursiveCall();
797 Py_DECREF_IMMORTAL(result);
804 int c = (*fcmp)(operand1, operand2);
805 c = adjust_tp_compare(c);
807 Py_LeaveRecursiveCall();
833 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
837 PyObject *result = BOOL_FROM(r);
838 Py_INCREF_IMMORTAL(result);
846 if (type1 != &PyString_Type && 0) {
847 f = PyString_Type.tp_richcompare;
850 PyObject *result = (*f)(operand2, operand1, Py_EQ);
852 if (result != Py_NotImplemented) {
853 Py_LeaveRecursiveCall();
858 Py_DECREF_IMMORTAL(result);
862 f = TP_RICHCOMPARE(type1);
864 PyObject *result = (*f)(operand1, operand2, Py_EQ);
866 if (result != Py_NotImplemented) {
867 Py_LeaveRecursiveCall();
872 Py_DECREF_IMMORTAL(result);
875 f = PyString_Type.tp_richcompare;
877 PyObject *result = (*f)(operand2, operand1, Py_EQ);
879 if (result != Py_NotImplemented) {
880 Py_LeaveRecursiveCall();
885 Py_DECREF_IMMORTAL(result);
890 if (PyInstance_Check(operand1)) {
891 cmpfunc fcmp = type1->tp_compare;
892 c = (*fcmp)(operand1, operand2);
895 c = (*fcmp)(operand1, operand2);
897 c = try_3way_compare(operand1, operand2);
901 if (type1 == &PyString_Type) {
902 Py_uintptr_t aa = (Py_uintptr_t)operand1;
903 Py_uintptr_t bb = (Py_uintptr_t)operand2;
905 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
906 }
else if (operand1 == Py_None) {
909 }
else if (operand2 == Py_None) {
912 }
else if (PyNumber_Check(operand1)) {
915 if (PyNumber_Check(operand2)) {
917 Py_uintptr_t aa = (Py_uintptr_t)type1;
918 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
920 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
924 }
else if (PyNumber_Check(operand2)) {
928 int s = strcmp(type1->tp_name,
"str");
936 Py_uintptr_t aa = (Py_uintptr_t)type1;
937 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
939 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
944 Py_LeaveRecursiveCall();
946 if (unlikely(c <= -2)) {
972 PyObject *result = BOOL_FROM(r);
973 Py_INCREF_IMMORTAL(result);
976 bool checked_reverse_op =
false;
979 if (type1 != &PyString_Type && Nuitka_Type_IsSubtype(&PyString_Type, type1)) {
980 f = PyString_Type.tp_richcompare;
983 checked_reverse_op =
true;
985 PyObject *result = (*f)(operand2, operand1, Py_EQ);
987 if (result != Py_NotImplemented) {
988 Py_LeaveRecursiveCall();
993 Py_DECREF_IMMORTAL(result);
997 f = TP_RICHCOMPARE(type1);
1000 PyObject *result = (*f)(operand1, operand2, Py_EQ);
1002 if (result != Py_NotImplemented) {
1003 Py_LeaveRecursiveCall();
1008 Py_DECREF_IMMORTAL(result);
1011 if (checked_reverse_op ==
false) {
1012 f = PyString_Type.tp_richcompare;
1015 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1017 if (result != Py_NotImplemented) {
1018 Py_LeaveRecursiveCall();
1023 Py_DECREF_IMMORTAL(result);
1027 Py_LeaveRecursiveCall();
1033 bool r = operand1 == operand2;
1034 PyObject *result = BOOL_FROM(r);
1035 Py_INCREF_IMMORTAL(result);
1039 bool r = operand1 != operand2;
1040 PyObject *result = BOOL_FROM(r);
1041 Py_INCREF_IMMORTAL(result);
1045#if PYTHON_VERSION < 0x360
1046 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == str()", type1->tp_name);
1048 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'str'", type1->tp_name);
1056#if PYTHON_VERSION < 0x300
1058PyObject *RICH_COMPARE_EQ_OBJECT_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
1060 if (&PyString_Type == Py_TYPE(operand2)) {
1061 return COMPARE_EQ_OBJECT_STR_STR(operand1, operand2);
1064#if PYTHON_VERSION < 0x300
1065 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1069 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1074 PyTypeObject *type2 = Py_TYPE(operand2);
1076#if PYTHON_VERSION < 0x300
1078 if (&PyString_Type == type2 && !0) {
1080 richcmpfunc frich = PyString_Type.tp_richcompare;
1082 if (frich != NULL) {
1083 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
1085 if (result != Py_NotImplemented) {
1086 Py_LeaveRecursiveCall();
1091 Py_DECREF_IMMORTAL(result);
1095 cmpfunc fcmp = NULL;
1098 int c = (*fcmp)(operand1, operand2);
1099 c = adjust_tp_compare(c);
1101 Py_LeaveRecursiveCall();
1127 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1131 PyObject *result = BOOL_FROM(r);
1132 Py_INCREF_IMMORTAL(result);
1140 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1141 f = TP_RICHCOMPARE(type2);
1144 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1146 if (result != Py_NotImplemented) {
1147 Py_LeaveRecursiveCall();
1152 Py_DECREF_IMMORTAL(result);
1156 f = PyString_Type.tp_richcompare;
1158 PyObject *result = (*f)(operand1, operand2, Py_EQ);
1160 if (result != Py_NotImplemented) {
1161 Py_LeaveRecursiveCall();
1166 Py_DECREF_IMMORTAL(result);
1169 f = TP_RICHCOMPARE(type2);
1171 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1173 if (result != Py_NotImplemented) {
1174 Py_LeaveRecursiveCall();
1179 Py_DECREF_IMMORTAL(result);
1185 cmpfunc fcmp = NULL;
1186 c = (*fcmp)(operand1, operand2);
1187 }
else if (PyInstance_Check(operand2)) {
1188 cmpfunc fcmp = type2->tp_compare;
1189 c = (*fcmp)(operand1, operand2);
1191 c = try_3way_compare(operand1, operand2);
1195 if (&PyString_Type == type2) {
1196 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1197 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1199 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1200 }
else if (operand1 == Py_None) {
1203 }
else if (operand2 == Py_None) {
1206 }
else if (PyNumber_Check(operand1)) {
1209 if (PyNumber_Check(operand2)) {
1211 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1212 Py_uintptr_t bb = (Py_uintptr_t)type2;
1214 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1218 }
else if (PyNumber_Check(operand2)) {
1222 int s = strcmp(
"str", type2->tp_name);
1230 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1231 Py_uintptr_t bb = (Py_uintptr_t)type2;
1233 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1238 Py_LeaveRecursiveCall();
1240 if (unlikely(c <= -2)) {
1266 PyObject *result = BOOL_FROM(r);
1267 Py_INCREF_IMMORTAL(result);
1270 bool checked_reverse_op =
false;
1273 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1274 f = TP_RICHCOMPARE(type2);
1277 checked_reverse_op =
true;
1279 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1281 if (result != Py_NotImplemented) {
1282 Py_LeaveRecursiveCall();
1287 Py_DECREF_IMMORTAL(result);
1291 f = PyString_Type.tp_richcompare;
1294 PyObject *result = (*f)(operand1, operand2, Py_EQ);
1296 if (result != Py_NotImplemented) {
1297 Py_LeaveRecursiveCall();
1302 Py_DECREF_IMMORTAL(result);
1305 if (checked_reverse_op ==
false) {
1306 f = TP_RICHCOMPARE(type2);
1309 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1311 if (result != Py_NotImplemented) {
1312 Py_LeaveRecursiveCall();
1317 Py_DECREF_IMMORTAL(result);
1321 Py_LeaveRecursiveCall();
1327 bool r = operand1 == operand2;
1328 PyObject *result = BOOL_FROM(r);
1329 Py_INCREF_IMMORTAL(result);
1333 bool r = operand1 != operand2;
1334 PyObject *result = BOOL_FROM(r);
1335 Py_INCREF_IMMORTAL(result);
1339#if PYTHON_VERSION < 0x360
1340 PyErr_Format(PyExc_TypeError,
"unorderable types: str() == %s()", type2->tp_name);
1342 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'str' and '%s'", type2->tp_name);
1350#if PYTHON_VERSION < 0x300
1352PyObject *RICH_COMPARE_EQ_OBJECT_STR_STR(PyObject *operand1, PyObject *operand2) {
1354 return COMPARE_EQ_OBJECT_STR_STR(operand1, operand2);
1358#if PYTHON_VERSION < 0x300
1359static bool COMPARE_EQ_CBOOL_STR_STR(PyObject *operand1, PyObject *operand2) {
1360 CHECK_OBJECT(operand1);
1361 assert(PyString_CheckExact(operand1));
1362 CHECK_OBJECT(operand2);
1363 assert(PyString_CheckExact(operand2));
1365 PyStringObject *a = (PyStringObject *)operand1;
1366 PyStringObject *b = (PyStringObject *)operand2;
1369 if (operand1 == operand2) {
1378 Py_ssize_t len_a = Py_SIZE(operand1);
1379 Py_ssize_t len_b = Py_SIZE(operand2);
1381 if (len_a != len_b) {
1389 if ((a->ob_sval[0] == b->ob_sval[0]) && (memcmp(a->ob_sval, b->ob_sval, len_a) == 0)) {
1407#if PYTHON_VERSION < 0x300
1409bool RICH_COMPARE_EQ_CBOOL_STR_STR(PyObject *operand1, PyObject *operand2) {
1411 return COMPARE_EQ_CBOOL_STR_STR(operand1, operand2);
1415#if PYTHON_VERSION < 0x300
1417nuitka_bool RICH_COMPARE_EQ_NBOOL_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
1419 if (Py_TYPE(operand1) == &PyString_Type) {
1420 return COMPARE_EQ_CBOOL_STR_STR(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1423#if PYTHON_VERSION < 0x300
1424 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1425 return NUITKA_BOOL_EXCEPTION;
1428 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1429 return NUITKA_BOOL_EXCEPTION;
1433 PyTypeObject *type1 = Py_TYPE(operand1);
1435#if PYTHON_VERSION < 0x300
1437 if (type1 == &PyString_Type && !0) {
1439 richcmpfunc frich = PyString_Type.tp_richcompare;
1441 if (frich != NULL) {
1442 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
1444 if (result != Py_NotImplemented) {
1445 Py_LeaveRecursiveCall();
1447 if (unlikely(result == NULL)) {
1448 return NUITKA_BOOL_EXCEPTION;
1452 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1458 Py_DECREF_IMMORTAL(result);
1462 cmpfunc fcmp = NULL;
1465 int c = (*fcmp)(operand1, operand2);
1466 c = adjust_tp_compare(c);
1468 Py_LeaveRecursiveCall();
1471 return NUITKA_BOOL_EXCEPTION;
1494 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1498 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1507 if (type1 != &PyString_Type && 0) {
1508 f = PyString_Type.tp_richcompare;
1511 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1513 if (result != Py_NotImplemented) {
1514 Py_LeaveRecursiveCall();
1516 if (unlikely(result == NULL)) {
1517 return NUITKA_BOOL_EXCEPTION;
1521 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1527 Py_DECREF_IMMORTAL(result);
1531 f = TP_RICHCOMPARE(type1);
1533 PyObject *result = (*f)(operand1, operand2, Py_EQ);
1535 if (result != Py_NotImplemented) {
1536 Py_LeaveRecursiveCall();
1538 if (unlikely(result == NULL)) {
1539 return NUITKA_BOOL_EXCEPTION;
1543 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1549 Py_DECREF_IMMORTAL(result);
1552 f = PyString_Type.tp_richcompare;
1554 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1556 if (result != Py_NotImplemented) {
1557 Py_LeaveRecursiveCall();
1559 if (unlikely(result == NULL)) {
1560 return NUITKA_BOOL_EXCEPTION;
1564 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1570 Py_DECREF_IMMORTAL(result);
1575 if (PyInstance_Check(operand1)) {
1576 cmpfunc fcmp = type1->tp_compare;
1577 c = (*fcmp)(operand1, operand2);
1579 cmpfunc fcmp = NULL;
1580 c = (*fcmp)(operand1, operand2);
1582 c = try_3way_compare(operand1, operand2);
1586 if (type1 == &PyString_Type) {
1587 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1588 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1590 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1591 }
else if (operand1 == Py_None) {
1594 }
else if (operand2 == Py_None) {
1597 }
else if (PyNumber_Check(operand1)) {
1600 if (PyNumber_Check(operand2)) {
1602 Py_uintptr_t aa = (Py_uintptr_t)type1;
1603 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
1605 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1609 }
else if (PyNumber_Check(operand2)) {
1613 int s = strcmp(type1->tp_name,
"str");
1621 Py_uintptr_t aa = (Py_uintptr_t)type1;
1622 Py_uintptr_t bb = (Py_uintptr_t)&PyString_Type;
1624 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1629 Py_LeaveRecursiveCall();
1631 if (unlikely(c <= -2)) {
1632 return NUITKA_BOOL_EXCEPTION;
1657 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1661 bool checked_reverse_op =
false;
1664 if (type1 != &PyString_Type && Nuitka_Type_IsSubtype(&PyString_Type, type1)) {
1665 f = PyString_Type.tp_richcompare;
1668 checked_reverse_op =
true;
1670 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1672 if (result != Py_NotImplemented) {
1673 Py_LeaveRecursiveCall();
1675 if (unlikely(result == NULL)) {
1676 return NUITKA_BOOL_EXCEPTION;
1680 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1686 Py_DECREF_IMMORTAL(result);
1690 f = TP_RICHCOMPARE(type1);
1693 PyObject *result = (*f)(operand1, operand2, Py_EQ);
1695 if (result != Py_NotImplemented) {
1696 Py_LeaveRecursiveCall();
1698 if (unlikely(result == NULL)) {
1699 return NUITKA_BOOL_EXCEPTION;
1703 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1709 Py_DECREF_IMMORTAL(result);
1712 if (checked_reverse_op ==
false) {
1713 f = PyString_Type.tp_richcompare;
1716 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1718 if (result != Py_NotImplemented) {
1719 Py_LeaveRecursiveCall();
1721 if (unlikely(result == NULL)) {
1722 return NUITKA_BOOL_EXCEPTION;
1726 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1732 Py_DECREF_IMMORTAL(result);
1736 Py_LeaveRecursiveCall();
1742 bool r = operand1 == operand2;
1743 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1748 bool r = operand1 != operand2;
1749 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1754#if PYTHON_VERSION < 0x360
1755 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == str()", type1->tp_name);
1757 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'str'", type1->tp_name);
1759 return NUITKA_BOOL_EXCEPTION;
1765#if PYTHON_VERSION < 0x300
1767nuitka_bool RICH_COMPARE_EQ_NBOOL_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
1769 if (&PyString_Type == Py_TYPE(operand2)) {
1770 return COMPARE_EQ_CBOOL_STR_STR(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1773#if PYTHON_VERSION < 0x300
1774 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
1775 return NUITKA_BOOL_EXCEPTION;
1778 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
1779 return NUITKA_BOOL_EXCEPTION;
1783 PyTypeObject *type2 = Py_TYPE(operand2);
1785#if PYTHON_VERSION < 0x300
1787 if (&PyString_Type == type2 && !0) {
1789 richcmpfunc frich = PyString_Type.tp_richcompare;
1791 if (frich != NULL) {
1792 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
1794 if (result != Py_NotImplemented) {
1795 Py_LeaveRecursiveCall();
1797 if (unlikely(result == NULL)) {
1798 return NUITKA_BOOL_EXCEPTION;
1802 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1808 Py_DECREF_IMMORTAL(result);
1812 cmpfunc fcmp = NULL;
1815 int c = (*fcmp)(operand1, operand2);
1816 c = adjust_tp_compare(c);
1818 Py_LeaveRecursiveCall();
1821 return NUITKA_BOOL_EXCEPTION;
1844 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
1848 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1857 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
1858 f = TP_RICHCOMPARE(type2);
1861 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1863 if (result != Py_NotImplemented) {
1864 Py_LeaveRecursiveCall();
1866 if (unlikely(result == NULL)) {
1867 return NUITKA_BOOL_EXCEPTION;
1871 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1877 Py_DECREF_IMMORTAL(result);
1881 f = PyString_Type.tp_richcompare;
1883 PyObject *result = (*f)(operand1, operand2, Py_EQ);
1885 if (result != Py_NotImplemented) {
1886 Py_LeaveRecursiveCall();
1888 if (unlikely(result == NULL)) {
1889 return NUITKA_BOOL_EXCEPTION;
1893 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1899 Py_DECREF_IMMORTAL(result);
1902 f = TP_RICHCOMPARE(type2);
1904 PyObject *result = (*f)(operand2, operand1, Py_EQ);
1906 if (result != Py_NotImplemented) {
1907 Py_LeaveRecursiveCall();
1909 if (unlikely(result == NULL)) {
1910 return NUITKA_BOOL_EXCEPTION;
1914 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1920 Py_DECREF_IMMORTAL(result);
1926 cmpfunc fcmp = NULL;
1927 c = (*fcmp)(operand1, operand2);
1928 }
else if (PyInstance_Check(operand2)) {
1929 cmpfunc fcmp = type2->tp_compare;
1930 c = (*fcmp)(operand1, operand2);
1932 c = try_3way_compare(operand1, operand2);
1936 if (&PyString_Type == type2) {
1937 Py_uintptr_t aa = (Py_uintptr_t)operand1;
1938 Py_uintptr_t bb = (Py_uintptr_t)operand2;
1940 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1941 }
else if (operand1 == Py_None) {
1944 }
else if (operand2 == Py_None) {
1947 }
else if (PyNumber_Check(operand1)) {
1950 if (PyNumber_Check(operand2)) {
1952 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1953 Py_uintptr_t bb = (Py_uintptr_t)type2;
1955 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1959 }
else if (PyNumber_Check(operand2)) {
1963 int s = strcmp(
"str", type2->tp_name);
1971 Py_uintptr_t aa = (Py_uintptr_t)&PyString_Type;
1972 Py_uintptr_t bb = (Py_uintptr_t)type2;
1974 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
1979 Py_LeaveRecursiveCall();
1981 if (unlikely(c <= -2)) {
1982 return NUITKA_BOOL_EXCEPTION;
2007 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2011 bool checked_reverse_op =
false;
2014 if (&PyString_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyString_Type)) {
2015 f = TP_RICHCOMPARE(type2);
2018 checked_reverse_op =
true;
2020 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2022 if (result != Py_NotImplemented) {
2023 Py_LeaveRecursiveCall();
2025 if (unlikely(result == NULL)) {
2026 return NUITKA_BOOL_EXCEPTION;
2030 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2036 Py_DECREF_IMMORTAL(result);
2040 f = PyString_Type.tp_richcompare;
2043 PyObject *result = (*f)(operand1, operand2, Py_EQ);
2045 if (result != Py_NotImplemented) {
2046 Py_LeaveRecursiveCall();
2048 if (unlikely(result == NULL)) {
2049 return NUITKA_BOOL_EXCEPTION;
2053 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2059 Py_DECREF_IMMORTAL(result);
2062 if (checked_reverse_op ==
false) {
2063 f = TP_RICHCOMPARE(type2);
2066 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2068 if (result != Py_NotImplemented) {
2069 Py_LeaveRecursiveCall();
2071 if (unlikely(result == NULL)) {
2072 return NUITKA_BOOL_EXCEPTION;
2076 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2082 Py_DECREF_IMMORTAL(result);
2086 Py_LeaveRecursiveCall();
2092 bool r = operand1 == operand2;
2093 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2098 bool r = operand1 != operand2;
2099 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2104#if PYTHON_VERSION < 0x360
2105 PyErr_Format(PyExc_TypeError,
"unorderable types: str() == %s()", type2->tp_name);
2107 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'str' and '%s'", type2->tp_name);
2109 return NUITKA_BOOL_EXCEPTION;
2115static PyObject *COMPARE_EQ_OBJECT_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2116 CHECK_OBJECT(operand1);
2117 assert(PyUnicode_CheckExact(operand1));
2118 CHECK_OBJECT(operand2);
2119 assert(PyUnicode_CheckExact(operand2));
2121 PyUnicodeObject *a = (PyUnicodeObject *)operand1;
2122 PyUnicodeObject *b = (PyUnicodeObject *)operand2;
2125 if (operand1 == operand2) {
2129 PyObject *result = BOOL_FROM(r);
2130 Py_INCREF_IMMORTAL(result);
2134#if PYTHON_VERSION >= 0x300
2137 Py_ssize_t len = PyUnicode_GET_LENGTH(a);
2138 if (PyUnicode_GET_LENGTH(b) != len) {
2141 int kind1 = PyUnicode_KIND(a);
2142#if PYTHON_VERSION < 0x3c0
2143 if (unlikely(kind1 == 0)) {
2144 NUITKA_MAY_BE_UNUSED
int res = _PyUnicode_Ready((PyObject *)a);
2146 kind1 = PyUnicode_KIND(a);
2151 int kind2 = PyUnicode_KIND(b);
2152#if PYTHON_VERSION < 0x3c0
2153 if (unlikely(kind2 == 0)) {
2154 NUITKA_MAY_BE_UNUSED
int res = _PyUnicode_Ready((PyObject *)b);
2156 kind2 = PyUnicode_KIND(b);
2161 if (kind1 != kind2) {
2164 const void *data1 = PyUnicode_DATA(a);
2165 const void *data2 = PyUnicode_DATA(b);
2167 int cmp = memcmp(data1, data2, len * kind1);
2172 PyObject *result = BOOL_FROM(r ==
true);
2173 Py_INCREF_IMMORTAL(result);
2178 Py_ssize_t len = PyUnicode_GET_LENGTH(a);
2179 if (PyUnicode_GET_LENGTH(b) != len) {
2182 const Py_UNICODE *data1 = a->str;
2183 const Py_UNICODE *data2 = b->str;
2185 int cmp = memcmp(data1, data2, len *
sizeof(Py_UNICODE));
2189 PyObject *result = BOOL_FROM(r ==
true);
2190 Py_INCREF_IMMORTAL(result);
2195PyObject *RICH_COMPARE_EQ_OBJECT_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
2197 if (Py_TYPE(operand1) == &PyUnicode_Type) {
2198 return COMPARE_EQ_OBJECT_UNICODE_UNICODE(operand1, operand2);
2201#if PYTHON_VERSION < 0x300
2202 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2206 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2211 PyTypeObject *type1 = Py_TYPE(operand1);
2213#if PYTHON_VERSION < 0x300
2215 if (type1 == &PyUnicode_Type && !0) {
2217 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2219 if (frich != NULL) {
2220 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
2222 if (result != Py_NotImplemented) {
2223 Py_LeaveRecursiveCall();
2228 Py_DECREF_IMMORTAL(result);
2232 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2235 int c = (*fcmp)(operand1, operand2);
2236 c = adjust_tp_compare(c);
2238 Py_LeaveRecursiveCall();
2264 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2268 PyObject *result = BOOL_FROM(r);
2269 Py_INCREF_IMMORTAL(result);
2277 if (type1 != &PyUnicode_Type && 0) {
2278 f = PyUnicode_Type.tp_richcompare;
2281 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2283 if (result != Py_NotImplemented) {
2284 Py_LeaveRecursiveCall();
2289 Py_DECREF_IMMORTAL(result);
2293 f = TP_RICHCOMPARE(type1);
2295 PyObject *result = (*f)(operand1, operand2, Py_EQ);
2297 if (result != Py_NotImplemented) {
2298 Py_LeaveRecursiveCall();
2303 Py_DECREF_IMMORTAL(result);
2306 f = PyUnicode_Type.tp_richcompare;
2308 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2310 if (result != Py_NotImplemented) {
2311 Py_LeaveRecursiveCall();
2316 Py_DECREF_IMMORTAL(result);
2321 if (PyInstance_Check(operand1)) {
2322 cmpfunc fcmp = type1->tp_compare;
2323 c = (*fcmp)(operand1, operand2);
2325 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2326 c = (*fcmp)(operand1, operand2);
2328 c = try_3way_compare(operand1, operand2);
2332 if (type1 == &PyUnicode_Type) {
2333 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2334 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2336 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2337 }
else if (operand1 == Py_None) {
2340 }
else if (operand2 == Py_None) {
2343 }
else if (PyNumber_Check(operand1)) {
2346 if (PyNumber_Check(operand2)) {
2348 Py_uintptr_t aa = (Py_uintptr_t)type1;
2349 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2351 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2355 }
else if (PyNumber_Check(operand2)) {
2359 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"unicode" :
"str"));
2367 Py_uintptr_t aa = (Py_uintptr_t)type1;
2368 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
2370 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2375 Py_LeaveRecursiveCall();
2377 if (unlikely(c <= -2)) {
2403 PyObject *result = BOOL_FROM(r);
2404 Py_INCREF_IMMORTAL(result);
2407 bool checked_reverse_op =
false;
2410 if (type1 != &PyUnicode_Type && Nuitka_Type_IsSubtype(&PyUnicode_Type, type1)) {
2411 f = PyUnicode_Type.tp_richcompare;
2414 checked_reverse_op =
true;
2416 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2418 if (result != Py_NotImplemented) {
2419 Py_LeaveRecursiveCall();
2424 Py_DECREF_IMMORTAL(result);
2428 f = TP_RICHCOMPARE(type1);
2431 PyObject *result = (*f)(operand1, operand2, Py_EQ);
2433 if (result != Py_NotImplemented) {
2434 Py_LeaveRecursiveCall();
2439 Py_DECREF_IMMORTAL(result);
2442 if (checked_reverse_op ==
false) {
2443 f = PyUnicode_Type.tp_richcompare;
2446 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2448 if (result != Py_NotImplemented) {
2449 Py_LeaveRecursiveCall();
2454 Py_DECREF_IMMORTAL(result);
2458 Py_LeaveRecursiveCall();
2464 bool r = operand1 == operand2;
2465 PyObject *result = BOOL_FROM(r);
2466 Py_INCREF_IMMORTAL(result);
2470 bool r = operand1 != operand2;
2471 PyObject *result = BOOL_FROM(r);
2472 Py_INCREF_IMMORTAL(result);
2476#if PYTHON_VERSION < 0x300
2477 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == unicode()", type1->tp_name);
2478#elif PYTHON_VERSION < 0x360
2479 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == str()", type1->tp_name);
2481 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'str'", type1->tp_name);
2489PyObject *RICH_COMPARE_EQ_OBJECT_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
2491 if (&PyUnicode_Type == Py_TYPE(operand2)) {
2492 return COMPARE_EQ_OBJECT_UNICODE_UNICODE(operand1, operand2);
2495#if PYTHON_VERSION < 0x300
2496 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2500 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2505 PyTypeObject *type2 = Py_TYPE(operand2);
2507#if PYTHON_VERSION < 0x300
2509 if (&PyUnicode_Type == type2 && !0) {
2511 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2513 if (frich != NULL) {
2514 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
2516 if (result != Py_NotImplemented) {
2517 Py_LeaveRecursiveCall();
2522 Py_DECREF_IMMORTAL(result);
2526 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2529 int c = (*fcmp)(operand1, operand2);
2530 c = adjust_tp_compare(c);
2532 Py_LeaveRecursiveCall();
2558 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2562 PyObject *result = BOOL_FROM(r);
2563 Py_INCREF_IMMORTAL(result);
2571 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
2572 f = TP_RICHCOMPARE(type2);
2575 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2577 if (result != Py_NotImplemented) {
2578 Py_LeaveRecursiveCall();
2583 Py_DECREF_IMMORTAL(result);
2587 f = PyUnicode_Type.tp_richcompare;
2589 PyObject *result = (*f)(operand1, operand2, Py_EQ);
2591 if (result != Py_NotImplemented) {
2592 Py_LeaveRecursiveCall();
2597 Py_DECREF_IMMORTAL(result);
2600 f = TP_RICHCOMPARE(type2);
2602 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2604 if (result != Py_NotImplemented) {
2605 Py_LeaveRecursiveCall();
2610 Py_DECREF_IMMORTAL(result);
2616 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2617 c = (*fcmp)(operand1, operand2);
2618 }
else if (PyInstance_Check(operand2)) {
2619 cmpfunc fcmp = type2->tp_compare;
2620 c = (*fcmp)(operand1, operand2);
2622 c = try_3way_compare(operand1, operand2);
2626 if (&PyUnicode_Type == type2) {
2627 Py_uintptr_t aa = (Py_uintptr_t)operand1;
2628 Py_uintptr_t bb = (Py_uintptr_t)operand2;
2630 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2631 }
else if (operand1 == Py_None) {
2634 }
else if (operand2 == Py_None) {
2637 }
else if (PyNumber_Check(operand1)) {
2640 if (PyNumber_Check(operand2)) {
2642 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
2643 Py_uintptr_t bb = (Py_uintptr_t)type2;
2645 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2649 }
else if (PyNumber_Check(operand2)) {
2653 int s = strcmp((PYTHON_VERSION < 0x300 ?
"unicode" :
"str"), type2->tp_name);
2661 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
2662 Py_uintptr_t bb = (Py_uintptr_t)type2;
2664 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
2669 Py_LeaveRecursiveCall();
2671 if (unlikely(c <= -2)) {
2697 PyObject *result = BOOL_FROM(r);
2698 Py_INCREF_IMMORTAL(result);
2701 bool checked_reverse_op =
false;
2704 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
2705 f = TP_RICHCOMPARE(type2);
2708 checked_reverse_op =
true;
2710 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2712 if (result != Py_NotImplemented) {
2713 Py_LeaveRecursiveCall();
2718 Py_DECREF_IMMORTAL(result);
2722 f = PyUnicode_Type.tp_richcompare;
2725 PyObject *result = (*f)(operand1, operand2, Py_EQ);
2727 if (result != Py_NotImplemented) {
2728 Py_LeaveRecursiveCall();
2733 Py_DECREF_IMMORTAL(result);
2736 if (checked_reverse_op ==
false) {
2737 f = TP_RICHCOMPARE(type2);
2740 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2742 if (result != Py_NotImplemented) {
2743 Py_LeaveRecursiveCall();
2748 Py_DECREF_IMMORTAL(result);
2752 Py_LeaveRecursiveCall();
2758 bool r = operand1 == operand2;
2759 PyObject *result = BOOL_FROM(r);
2760 Py_INCREF_IMMORTAL(result);
2764 bool r = operand1 != operand2;
2765 PyObject *result = BOOL_FROM(r);
2766 Py_INCREF_IMMORTAL(result);
2770#if PYTHON_VERSION < 0x300
2771 PyErr_Format(PyExc_TypeError,
"unorderable types: unicode() == %s()", type2->tp_name);
2772#elif PYTHON_VERSION < 0x360
2773 PyErr_Format(PyExc_TypeError,
"unorderable types: str() == %s()", type2->tp_name);
2775 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'str' and '%s'", type2->tp_name);
2784PyObject *RICH_COMPARE_EQ_OBJECT_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2786 return COMPARE_EQ_OBJECT_UNICODE_UNICODE(operand1, operand2);
2789static bool COMPARE_EQ_CBOOL_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2790 CHECK_OBJECT(operand1);
2791 assert(PyUnicode_CheckExact(operand1));
2792 CHECK_OBJECT(operand2);
2793 assert(PyUnicode_CheckExact(operand2));
2795 PyUnicodeObject *a = (PyUnicodeObject *)operand1;
2796 PyUnicodeObject *b = (PyUnicodeObject *)operand2;
2799 if (operand1 == operand2) {
2808#if PYTHON_VERSION >= 0x300
2811 Py_ssize_t len = PyUnicode_GET_LENGTH(a);
2812 if (PyUnicode_GET_LENGTH(b) != len) {
2815 int kind1 = PyUnicode_KIND(a);
2816#if PYTHON_VERSION < 0x3c0
2817 if (unlikely(kind1 == 0)) {
2818 NUITKA_MAY_BE_UNUSED
int res = _PyUnicode_Ready((PyObject *)a);
2820 kind1 = PyUnicode_KIND(a);
2825 int kind2 = PyUnicode_KIND(b);
2826#if PYTHON_VERSION < 0x3c0
2827 if (unlikely(kind2 == 0)) {
2828 NUITKA_MAY_BE_UNUSED
int res = _PyUnicode_Ready((PyObject *)b);
2830 kind2 = PyUnicode_KIND(b);
2835 if (kind1 != kind2) {
2838 const void *data1 = PyUnicode_DATA(a);
2839 const void *data2 = PyUnicode_DATA(b);
2841 int cmp = memcmp(data1, data2, len * kind1);
2846 bool result = r ==
true;
2852 Py_ssize_t len = PyUnicode_GET_LENGTH(a);
2853 if (PyUnicode_GET_LENGTH(b) != len) {
2856 const Py_UNICODE *data1 = a->str;
2857 const Py_UNICODE *data2 = b->str;
2859 int cmp = memcmp(data1, data2, len *
sizeof(Py_UNICODE));
2863 bool result = r ==
true;
2870bool RICH_COMPARE_EQ_CBOOL_UNICODE_UNICODE(PyObject *operand1, PyObject *operand2) {
2872 return COMPARE_EQ_CBOOL_UNICODE_UNICODE(operand1, operand2);
2876nuitka_bool RICH_COMPARE_EQ_NBOOL_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
2878 if (Py_TYPE(operand1) == &PyUnicode_Type) {
2879 return COMPARE_EQ_CBOOL_UNICODE_UNICODE(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2882#if PYTHON_VERSION < 0x300
2883 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
2884 return NUITKA_BOOL_EXCEPTION;
2887 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
2888 return NUITKA_BOOL_EXCEPTION;
2892 PyTypeObject *type1 = Py_TYPE(operand1);
2894#if PYTHON_VERSION < 0x300
2896 if (type1 == &PyUnicode_Type && !0) {
2898 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
2900 if (frich != NULL) {
2901 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
2903 if (result != Py_NotImplemented) {
2904 Py_LeaveRecursiveCall();
2906 if (unlikely(result == NULL)) {
2907 return NUITKA_BOOL_EXCEPTION;
2911 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2917 Py_DECREF_IMMORTAL(result);
2921 cmpfunc fcmp = PyUnicode_Type.tp_compare;
2924 int c = (*fcmp)(operand1, operand2);
2925 c = adjust_tp_compare(c);
2927 Py_LeaveRecursiveCall();
2930 return NUITKA_BOOL_EXCEPTION;
2953 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
2957 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2966 if (type1 != &PyUnicode_Type && 0) {
2967 f = PyUnicode_Type.tp_richcompare;
2970 PyObject *result = (*f)(operand2, operand1, Py_EQ);
2972 if (result != Py_NotImplemented) {
2973 Py_LeaveRecursiveCall();
2975 if (unlikely(result == NULL)) {
2976 return NUITKA_BOOL_EXCEPTION;
2980 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2986 Py_DECREF_IMMORTAL(result);
2990 f = TP_RICHCOMPARE(type1);
2992 PyObject *result = (*f)(operand1, operand2, Py_EQ);
2994 if (result != Py_NotImplemented) {
2995 Py_LeaveRecursiveCall();
2997 if (unlikely(result == NULL)) {
2998 return NUITKA_BOOL_EXCEPTION;
3002 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3008 Py_DECREF_IMMORTAL(result);
3011 f = PyUnicode_Type.tp_richcompare;
3013 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3015 if (result != Py_NotImplemented) {
3016 Py_LeaveRecursiveCall();
3018 if (unlikely(result == NULL)) {
3019 return NUITKA_BOOL_EXCEPTION;
3023 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3029 Py_DECREF_IMMORTAL(result);
3034 if (PyInstance_Check(operand1)) {
3035 cmpfunc fcmp = type1->tp_compare;
3036 c = (*fcmp)(operand1, operand2);
3038 cmpfunc fcmp = PyUnicode_Type.tp_compare;
3039 c = (*fcmp)(operand1, operand2);
3041 c = try_3way_compare(operand1, operand2);
3045 if (type1 == &PyUnicode_Type) {
3046 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3047 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3049 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3050 }
else if (operand1 == Py_None) {
3053 }
else if (operand2 == Py_None) {
3056 }
else if (PyNumber_Check(operand1)) {
3059 if (PyNumber_Check(operand2)) {
3061 Py_uintptr_t aa = (Py_uintptr_t)type1;
3062 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
3064 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3068 }
else if (PyNumber_Check(operand2)) {
3072 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"unicode" :
"str"));
3080 Py_uintptr_t aa = (Py_uintptr_t)type1;
3081 Py_uintptr_t bb = (Py_uintptr_t)&PyUnicode_Type;
3083 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3088 Py_LeaveRecursiveCall();
3090 if (unlikely(c <= -2)) {
3091 return NUITKA_BOOL_EXCEPTION;
3116 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3120 bool checked_reverse_op =
false;
3123 if (type1 != &PyUnicode_Type && Nuitka_Type_IsSubtype(&PyUnicode_Type, type1)) {
3124 f = PyUnicode_Type.tp_richcompare;
3127 checked_reverse_op =
true;
3129 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3131 if (result != Py_NotImplemented) {
3132 Py_LeaveRecursiveCall();
3134 if (unlikely(result == NULL)) {
3135 return NUITKA_BOOL_EXCEPTION;
3139 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3145 Py_DECREF_IMMORTAL(result);
3149 f = TP_RICHCOMPARE(type1);
3152 PyObject *result = (*f)(operand1, operand2, Py_EQ);
3154 if (result != Py_NotImplemented) {
3155 Py_LeaveRecursiveCall();
3157 if (unlikely(result == NULL)) {
3158 return NUITKA_BOOL_EXCEPTION;
3162 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3168 Py_DECREF_IMMORTAL(result);
3171 if (checked_reverse_op ==
false) {
3172 f = PyUnicode_Type.tp_richcompare;
3175 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3177 if (result != Py_NotImplemented) {
3178 Py_LeaveRecursiveCall();
3180 if (unlikely(result == NULL)) {
3181 return NUITKA_BOOL_EXCEPTION;
3185 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3191 Py_DECREF_IMMORTAL(result);
3195 Py_LeaveRecursiveCall();
3201 bool r = operand1 == operand2;
3202 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3207 bool r = operand1 != operand2;
3208 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3213#if PYTHON_VERSION < 0x300
3214 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == unicode()", type1->tp_name);
3215#elif PYTHON_VERSION < 0x360
3216 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == str()", type1->tp_name);
3218 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'str'", type1->tp_name);
3220 return NUITKA_BOOL_EXCEPTION;
3226nuitka_bool RICH_COMPARE_EQ_NBOOL_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
3228 if (&PyUnicode_Type == Py_TYPE(operand2)) {
3229 return COMPARE_EQ_CBOOL_UNICODE_UNICODE(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3232#if PYTHON_VERSION < 0x300
3233 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3234 return NUITKA_BOOL_EXCEPTION;
3237 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3238 return NUITKA_BOOL_EXCEPTION;
3242 PyTypeObject *type2 = Py_TYPE(operand2);
3244#if PYTHON_VERSION < 0x300
3246 if (&PyUnicode_Type == type2 && !0) {
3248 richcmpfunc frich = PyUnicode_Type.tp_richcompare;
3250 if (frich != NULL) {
3251 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
3253 if (result != Py_NotImplemented) {
3254 Py_LeaveRecursiveCall();
3256 if (unlikely(result == NULL)) {
3257 return NUITKA_BOOL_EXCEPTION;
3261 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3267 Py_DECREF_IMMORTAL(result);
3271 cmpfunc fcmp = PyUnicode_Type.tp_compare;
3274 int c = (*fcmp)(operand1, operand2);
3275 c = adjust_tp_compare(c);
3277 Py_LeaveRecursiveCall();
3280 return NUITKA_BOOL_EXCEPTION;
3303 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3307 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3316 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
3317 f = TP_RICHCOMPARE(type2);
3320 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3322 if (result != Py_NotImplemented) {
3323 Py_LeaveRecursiveCall();
3325 if (unlikely(result == NULL)) {
3326 return NUITKA_BOOL_EXCEPTION;
3330 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3336 Py_DECREF_IMMORTAL(result);
3340 f = PyUnicode_Type.tp_richcompare;
3342 PyObject *result = (*f)(operand1, operand2, Py_EQ);
3344 if (result != Py_NotImplemented) {
3345 Py_LeaveRecursiveCall();
3347 if (unlikely(result == NULL)) {
3348 return NUITKA_BOOL_EXCEPTION;
3352 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3358 Py_DECREF_IMMORTAL(result);
3361 f = TP_RICHCOMPARE(type2);
3363 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3365 if (result != Py_NotImplemented) {
3366 Py_LeaveRecursiveCall();
3368 if (unlikely(result == NULL)) {
3369 return NUITKA_BOOL_EXCEPTION;
3373 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3379 Py_DECREF_IMMORTAL(result);
3385 cmpfunc fcmp = PyUnicode_Type.tp_compare;
3386 c = (*fcmp)(operand1, operand2);
3387 }
else if (PyInstance_Check(operand2)) {
3388 cmpfunc fcmp = type2->tp_compare;
3389 c = (*fcmp)(operand1, operand2);
3391 c = try_3way_compare(operand1, operand2);
3395 if (&PyUnicode_Type == type2) {
3396 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3397 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3399 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3400 }
else if (operand1 == Py_None) {
3403 }
else if (operand2 == Py_None) {
3406 }
else if (PyNumber_Check(operand1)) {
3409 if (PyNumber_Check(operand2)) {
3411 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
3412 Py_uintptr_t bb = (Py_uintptr_t)type2;
3414 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3418 }
else if (PyNumber_Check(operand2)) {
3422 int s = strcmp((PYTHON_VERSION < 0x300 ?
"unicode" :
"str"), type2->tp_name);
3430 Py_uintptr_t aa = (Py_uintptr_t)&PyUnicode_Type;
3431 Py_uintptr_t bb = (Py_uintptr_t)type2;
3433 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3438 Py_LeaveRecursiveCall();
3440 if (unlikely(c <= -2)) {
3441 return NUITKA_BOOL_EXCEPTION;
3466 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3470 bool checked_reverse_op =
false;
3473 if (&PyUnicode_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyUnicode_Type)) {
3474 f = TP_RICHCOMPARE(type2);
3477 checked_reverse_op =
true;
3479 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3481 if (result != Py_NotImplemented) {
3482 Py_LeaveRecursiveCall();
3484 if (unlikely(result == NULL)) {
3485 return NUITKA_BOOL_EXCEPTION;
3489 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3495 Py_DECREF_IMMORTAL(result);
3499 f = PyUnicode_Type.tp_richcompare;
3502 PyObject *result = (*f)(operand1, operand2, Py_EQ);
3504 if (result != Py_NotImplemented) {
3505 Py_LeaveRecursiveCall();
3507 if (unlikely(result == NULL)) {
3508 return NUITKA_BOOL_EXCEPTION;
3512 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3518 Py_DECREF_IMMORTAL(result);
3521 if (checked_reverse_op ==
false) {
3522 f = TP_RICHCOMPARE(type2);
3525 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3527 if (result != Py_NotImplemented) {
3528 Py_LeaveRecursiveCall();
3530 if (unlikely(result == NULL)) {
3531 return NUITKA_BOOL_EXCEPTION;
3535 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3541 Py_DECREF_IMMORTAL(result);
3545 Py_LeaveRecursiveCall();
3551 bool r = operand1 == operand2;
3552 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3557 bool r = operand1 != operand2;
3558 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3563#if PYTHON_VERSION < 0x300
3564 PyErr_Format(PyExc_TypeError,
"unorderable types: unicode() == %s()", type2->tp_name);
3565#elif PYTHON_VERSION < 0x360
3566 PyErr_Format(PyExc_TypeError,
"unorderable types: str() == %s()", type2->tp_name);
3568 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'str' and '%s'", type2->tp_name);
3570 return NUITKA_BOOL_EXCEPTION;
3575#if PYTHON_VERSION >= 0x300
3576static PyObject *COMPARE_EQ_OBJECT_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
3577 CHECK_OBJECT(operand1);
3578 assert(PyBytes_CheckExact(operand1));
3579 CHECK_OBJECT(operand2);
3580 assert(PyBytes_CheckExact(operand2));
3582 PyBytesObject *a = (PyBytesObject *)operand1;
3583 PyBytesObject *b = (PyBytesObject *)operand2;
3586 if (operand1 == operand2) {
3590 PyObject *result = BOOL_FROM(r);
3591 Py_INCREF_IMMORTAL(result);
3595 Py_ssize_t len_a = Py_SIZE(operand1);
3596 Py_ssize_t len_b = Py_SIZE(operand2);
3598 if (len_a != len_b) {
3602 PyObject *result = BOOL_FROM(r);
3603 Py_INCREF_IMMORTAL(result);
3606 if ((a->ob_sval[0] == b->ob_sval[0]) && (memcmp(a->ob_sval, b->ob_sval, len_a) == 0)) {
3610 PyObject *result = BOOL_FROM(r);
3611 Py_INCREF_IMMORTAL(result);
3617 PyObject *result = BOOL_FROM(r);
3618 Py_INCREF_IMMORTAL(result);
3624#if PYTHON_VERSION >= 0x300
3626PyObject *RICH_COMPARE_EQ_OBJECT_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
3628 if (Py_TYPE(operand1) == &PyBytes_Type) {
3629 return COMPARE_EQ_OBJECT_BYTES_BYTES(operand1, operand2);
3632#if PYTHON_VERSION < 0x300
3633 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3637 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3642 PyTypeObject *type1 = Py_TYPE(operand1);
3644#if PYTHON_VERSION < 0x300
3646 if (type1 == &PyBytes_Type && !0) {
3648 richcmpfunc frich = PyBytes_Type.tp_richcompare;
3650 if (frich != NULL) {
3651 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
3653 if (result != Py_NotImplemented) {
3654 Py_LeaveRecursiveCall();
3659 Py_DECREF_IMMORTAL(result);
3663 cmpfunc fcmp = NULL;
3666 int c = (*fcmp)(operand1, operand2);
3667 c = adjust_tp_compare(c);
3669 Py_LeaveRecursiveCall();
3695 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3699 PyObject *result = BOOL_FROM(r);
3700 Py_INCREF_IMMORTAL(result);
3708 if (type1 != &PyBytes_Type && 0) {
3709 f = PyBytes_Type.tp_richcompare;
3712 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3714 if (result != Py_NotImplemented) {
3715 Py_LeaveRecursiveCall();
3720 Py_DECREF_IMMORTAL(result);
3724 f = TP_RICHCOMPARE(type1);
3726 PyObject *result = (*f)(operand1, operand2, Py_EQ);
3728 if (result != Py_NotImplemented) {
3729 Py_LeaveRecursiveCall();
3734 Py_DECREF_IMMORTAL(result);
3737 f = PyBytes_Type.tp_richcompare;
3739 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3741 if (result != Py_NotImplemented) {
3742 Py_LeaveRecursiveCall();
3747 Py_DECREF_IMMORTAL(result);
3752 if (PyInstance_Check(operand1)) {
3753 cmpfunc fcmp = type1->tp_compare;
3754 c = (*fcmp)(operand1, operand2);
3756 cmpfunc fcmp = NULL;
3757 c = (*fcmp)(operand1, operand2);
3759 c = try_3way_compare(operand1, operand2);
3763 if (type1 == &PyBytes_Type) {
3764 Py_uintptr_t aa = (Py_uintptr_t)operand1;
3765 Py_uintptr_t bb = (Py_uintptr_t)operand2;
3767 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3768 }
else if (operand1 == Py_None) {
3771 }
else if (operand2 == Py_None) {
3774 }
else if (PyNumber_Check(operand1)) {
3777 if (PyNumber_Check(operand2)) {
3779 Py_uintptr_t aa = (Py_uintptr_t)type1;
3780 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
3782 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3786 }
else if (PyNumber_Check(operand2)) {
3790 int s = strcmp(type1->tp_name,
"bytes");
3798 Py_uintptr_t aa = (Py_uintptr_t)type1;
3799 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
3801 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
3806 Py_LeaveRecursiveCall();
3808 if (unlikely(c <= -2)) {
3834 PyObject *result = BOOL_FROM(r);
3835 Py_INCREF_IMMORTAL(result);
3838 bool checked_reverse_op =
false;
3841 if (type1 != &PyBytes_Type && Nuitka_Type_IsSubtype(&PyBytes_Type, type1)) {
3842 f = PyBytes_Type.tp_richcompare;
3845 checked_reverse_op =
true;
3847 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3849 if (result != Py_NotImplemented) {
3850 Py_LeaveRecursiveCall();
3855 Py_DECREF_IMMORTAL(result);
3859 f = TP_RICHCOMPARE(type1);
3862 PyObject *result = (*f)(operand1, operand2, Py_EQ);
3864 if (result != Py_NotImplemented) {
3865 Py_LeaveRecursiveCall();
3870 Py_DECREF_IMMORTAL(result);
3873 if (checked_reverse_op ==
false) {
3874 f = PyBytes_Type.tp_richcompare;
3877 PyObject *result = (*f)(operand2, operand1, Py_EQ);
3879 if (result != Py_NotImplemented) {
3880 Py_LeaveRecursiveCall();
3885 Py_DECREF_IMMORTAL(result);
3889 Py_LeaveRecursiveCall();
3895 bool r = operand1 == operand2;
3896 PyObject *result = BOOL_FROM(r);
3897 Py_INCREF_IMMORTAL(result);
3901 bool r = operand1 != operand2;
3902 PyObject *result = BOOL_FROM(r);
3903 Py_INCREF_IMMORTAL(result);
3907#if PYTHON_VERSION < 0x360
3908 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == bytes()", type1->tp_name);
3910 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'bytes'", type1->tp_name);
3918#if PYTHON_VERSION >= 0x300
3920PyObject *RICH_COMPARE_EQ_OBJECT_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
3922 if (&PyBytes_Type == Py_TYPE(operand2)) {
3923 return COMPARE_EQ_OBJECT_BYTES_BYTES(operand1, operand2);
3926#if PYTHON_VERSION < 0x300
3927 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
3931 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
3936 PyTypeObject *type2 = Py_TYPE(operand2);
3938#if PYTHON_VERSION < 0x300
3940 if (&PyBytes_Type == type2 && !0) {
3942 richcmpfunc frich = PyBytes_Type.tp_richcompare;
3944 if (frich != NULL) {
3945 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
3947 if (result != Py_NotImplemented) {
3948 Py_LeaveRecursiveCall();
3953 Py_DECREF_IMMORTAL(result);
3957 cmpfunc fcmp = NULL;
3960 int c = (*fcmp)(operand1, operand2);
3961 c = adjust_tp_compare(c);
3963 Py_LeaveRecursiveCall();
3989 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
3993 PyObject *result = BOOL_FROM(r);
3994 Py_INCREF_IMMORTAL(result);
4002 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4003 f = TP_RICHCOMPARE(type2);
4006 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4008 if (result != Py_NotImplemented) {
4009 Py_LeaveRecursiveCall();
4014 Py_DECREF_IMMORTAL(result);
4018 f = PyBytes_Type.tp_richcompare;
4020 PyObject *result = (*f)(operand1, operand2, Py_EQ);
4022 if (result != Py_NotImplemented) {
4023 Py_LeaveRecursiveCall();
4028 Py_DECREF_IMMORTAL(result);
4031 f = TP_RICHCOMPARE(type2);
4033 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4035 if (result != Py_NotImplemented) {
4036 Py_LeaveRecursiveCall();
4041 Py_DECREF_IMMORTAL(result);
4047 cmpfunc fcmp = NULL;
4048 c = (*fcmp)(operand1, operand2);
4049 }
else if (PyInstance_Check(operand2)) {
4050 cmpfunc fcmp = type2->tp_compare;
4051 c = (*fcmp)(operand1, operand2);
4053 c = try_3way_compare(operand1, operand2);
4057 if (&PyBytes_Type == type2) {
4058 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4059 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4061 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4062 }
else if (operand1 == Py_None) {
4065 }
else if (operand2 == Py_None) {
4068 }
else if (PyNumber_Check(operand1)) {
4071 if (PyNumber_Check(operand2)) {
4073 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4074 Py_uintptr_t bb = (Py_uintptr_t)type2;
4076 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4080 }
else if (PyNumber_Check(operand2)) {
4084 int s = strcmp(
"bytes", type2->tp_name);
4092 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4093 Py_uintptr_t bb = (Py_uintptr_t)type2;
4095 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4100 Py_LeaveRecursiveCall();
4102 if (unlikely(c <= -2)) {
4128 PyObject *result = BOOL_FROM(r);
4129 Py_INCREF_IMMORTAL(result);
4132 bool checked_reverse_op =
false;
4135 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4136 f = TP_RICHCOMPARE(type2);
4139 checked_reverse_op =
true;
4141 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4143 if (result != Py_NotImplemented) {
4144 Py_LeaveRecursiveCall();
4149 Py_DECREF_IMMORTAL(result);
4153 f = PyBytes_Type.tp_richcompare;
4156 PyObject *result = (*f)(operand1, operand2, Py_EQ);
4158 if (result != Py_NotImplemented) {
4159 Py_LeaveRecursiveCall();
4164 Py_DECREF_IMMORTAL(result);
4167 if (checked_reverse_op ==
false) {
4168 f = TP_RICHCOMPARE(type2);
4171 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4173 if (result != Py_NotImplemented) {
4174 Py_LeaveRecursiveCall();
4179 Py_DECREF_IMMORTAL(result);
4183 Py_LeaveRecursiveCall();
4189 bool r = operand1 == operand2;
4190 PyObject *result = BOOL_FROM(r);
4191 Py_INCREF_IMMORTAL(result);
4195 bool r = operand1 != operand2;
4196 PyObject *result = BOOL_FROM(r);
4197 Py_INCREF_IMMORTAL(result);
4201#if PYTHON_VERSION < 0x360
4202 PyErr_Format(PyExc_TypeError,
"unorderable types: bytes() == %s()", type2->tp_name);
4204 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'bytes' and '%s'", type2->tp_name);
4212#if PYTHON_VERSION >= 0x300
4214PyObject *RICH_COMPARE_EQ_OBJECT_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4216 return COMPARE_EQ_OBJECT_BYTES_BYTES(operand1, operand2);
4220#if PYTHON_VERSION >= 0x300
4221static bool COMPARE_EQ_CBOOL_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4222 CHECK_OBJECT(operand1);
4223 assert(PyBytes_CheckExact(operand1));
4224 CHECK_OBJECT(operand2);
4225 assert(PyBytes_CheckExact(operand2));
4227 PyBytesObject *a = (PyBytesObject *)operand1;
4228 PyBytesObject *b = (PyBytesObject *)operand2;
4231 if (operand1 == operand2) {
4240 Py_ssize_t len_a = Py_SIZE(operand1);
4241 Py_ssize_t len_b = Py_SIZE(operand2);
4243 if (len_a != len_b) {
4251 if ((a->ob_sval[0] == b->ob_sval[0]) && (memcmp(a->ob_sval, b->ob_sval, len_a) == 0)) {
4269#if PYTHON_VERSION >= 0x300
4271bool RICH_COMPARE_EQ_CBOOL_BYTES_BYTES(PyObject *operand1, PyObject *operand2) {
4273 return COMPARE_EQ_CBOOL_BYTES_BYTES(operand1, operand2);
4277#if PYTHON_VERSION >= 0x300
4279nuitka_bool RICH_COMPARE_EQ_NBOOL_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
4281 if (Py_TYPE(operand1) == &PyBytes_Type) {
4282 return COMPARE_EQ_CBOOL_BYTES_BYTES(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4285#if PYTHON_VERSION < 0x300
4286 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4287 return NUITKA_BOOL_EXCEPTION;
4290 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4291 return NUITKA_BOOL_EXCEPTION;
4295 PyTypeObject *type1 = Py_TYPE(operand1);
4297#if PYTHON_VERSION < 0x300
4299 if (type1 == &PyBytes_Type && !0) {
4301 richcmpfunc frich = PyBytes_Type.tp_richcompare;
4303 if (frich != NULL) {
4304 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
4306 if (result != Py_NotImplemented) {
4307 Py_LeaveRecursiveCall();
4309 if (unlikely(result == NULL)) {
4310 return NUITKA_BOOL_EXCEPTION;
4314 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4320 Py_DECREF_IMMORTAL(result);
4324 cmpfunc fcmp = NULL;
4327 int c = (*fcmp)(operand1, operand2);
4328 c = adjust_tp_compare(c);
4330 Py_LeaveRecursiveCall();
4333 return NUITKA_BOOL_EXCEPTION;
4356 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4360 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4369 if (type1 != &PyBytes_Type && 0) {
4370 f = PyBytes_Type.tp_richcompare;
4373 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4375 if (result != Py_NotImplemented) {
4376 Py_LeaveRecursiveCall();
4378 if (unlikely(result == NULL)) {
4379 return NUITKA_BOOL_EXCEPTION;
4383 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4389 Py_DECREF_IMMORTAL(result);
4393 f = TP_RICHCOMPARE(type1);
4395 PyObject *result = (*f)(operand1, operand2, Py_EQ);
4397 if (result != Py_NotImplemented) {
4398 Py_LeaveRecursiveCall();
4400 if (unlikely(result == NULL)) {
4401 return NUITKA_BOOL_EXCEPTION;
4405 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4411 Py_DECREF_IMMORTAL(result);
4414 f = PyBytes_Type.tp_richcompare;
4416 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4418 if (result != Py_NotImplemented) {
4419 Py_LeaveRecursiveCall();
4421 if (unlikely(result == NULL)) {
4422 return NUITKA_BOOL_EXCEPTION;
4426 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4432 Py_DECREF_IMMORTAL(result);
4437 if (PyInstance_Check(operand1)) {
4438 cmpfunc fcmp = type1->tp_compare;
4439 c = (*fcmp)(operand1, operand2);
4441 cmpfunc fcmp = NULL;
4442 c = (*fcmp)(operand1, operand2);
4444 c = try_3way_compare(operand1, operand2);
4448 if (type1 == &PyBytes_Type) {
4449 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4450 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4452 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4453 }
else if (operand1 == Py_None) {
4456 }
else if (operand2 == Py_None) {
4459 }
else if (PyNumber_Check(operand1)) {
4462 if (PyNumber_Check(operand2)) {
4464 Py_uintptr_t aa = (Py_uintptr_t)type1;
4465 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
4467 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4471 }
else if (PyNumber_Check(operand2)) {
4475 int s = strcmp(type1->tp_name,
"bytes");
4483 Py_uintptr_t aa = (Py_uintptr_t)type1;
4484 Py_uintptr_t bb = (Py_uintptr_t)&PyBytes_Type;
4486 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4491 Py_LeaveRecursiveCall();
4493 if (unlikely(c <= -2)) {
4494 return NUITKA_BOOL_EXCEPTION;
4519 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4523 bool checked_reverse_op =
false;
4526 if (type1 != &PyBytes_Type && Nuitka_Type_IsSubtype(&PyBytes_Type, type1)) {
4527 f = PyBytes_Type.tp_richcompare;
4530 checked_reverse_op =
true;
4532 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4534 if (result != Py_NotImplemented) {
4535 Py_LeaveRecursiveCall();
4537 if (unlikely(result == NULL)) {
4538 return NUITKA_BOOL_EXCEPTION;
4542 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4548 Py_DECREF_IMMORTAL(result);
4552 f = TP_RICHCOMPARE(type1);
4555 PyObject *result = (*f)(operand1, operand2, Py_EQ);
4557 if (result != Py_NotImplemented) {
4558 Py_LeaveRecursiveCall();
4560 if (unlikely(result == NULL)) {
4561 return NUITKA_BOOL_EXCEPTION;
4565 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4571 Py_DECREF_IMMORTAL(result);
4574 if (checked_reverse_op ==
false) {
4575 f = PyBytes_Type.tp_richcompare;
4578 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4580 if (result != Py_NotImplemented) {
4581 Py_LeaveRecursiveCall();
4583 if (unlikely(result == NULL)) {
4584 return NUITKA_BOOL_EXCEPTION;
4588 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4594 Py_DECREF_IMMORTAL(result);
4598 Py_LeaveRecursiveCall();
4604 bool r = operand1 == operand2;
4605 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4610 bool r = operand1 != operand2;
4611 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4616#if PYTHON_VERSION < 0x360
4617 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == bytes()", type1->tp_name);
4619 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'bytes'", type1->tp_name);
4621 return NUITKA_BOOL_EXCEPTION;
4627#if PYTHON_VERSION >= 0x300
4629nuitka_bool RICH_COMPARE_EQ_NBOOL_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
4631 if (&PyBytes_Type == Py_TYPE(operand2)) {
4632 return COMPARE_EQ_CBOOL_BYTES_BYTES(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4635#if PYTHON_VERSION < 0x300
4636 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4637 return NUITKA_BOOL_EXCEPTION;
4640 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4641 return NUITKA_BOOL_EXCEPTION;
4645 PyTypeObject *type2 = Py_TYPE(operand2);
4647#if PYTHON_VERSION < 0x300
4649 if (&PyBytes_Type == type2 && !0) {
4651 richcmpfunc frich = PyBytes_Type.tp_richcompare;
4653 if (frich != NULL) {
4654 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
4656 if (result != Py_NotImplemented) {
4657 Py_LeaveRecursiveCall();
4659 if (unlikely(result == NULL)) {
4660 return NUITKA_BOOL_EXCEPTION;
4664 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4670 Py_DECREF_IMMORTAL(result);
4674 cmpfunc fcmp = NULL;
4677 int c = (*fcmp)(operand1, operand2);
4678 c = adjust_tp_compare(c);
4680 Py_LeaveRecursiveCall();
4683 return NUITKA_BOOL_EXCEPTION;
4706 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
4710 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4719 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4720 f = TP_RICHCOMPARE(type2);
4723 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4725 if (result != Py_NotImplemented) {
4726 Py_LeaveRecursiveCall();
4728 if (unlikely(result == NULL)) {
4729 return NUITKA_BOOL_EXCEPTION;
4733 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4739 Py_DECREF_IMMORTAL(result);
4743 f = PyBytes_Type.tp_richcompare;
4745 PyObject *result = (*f)(operand1, operand2, Py_EQ);
4747 if (result != Py_NotImplemented) {
4748 Py_LeaveRecursiveCall();
4750 if (unlikely(result == NULL)) {
4751 return NUITKA_BOOL_EXCEPTION;
4755 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4761 Py_DECREF_IMMORTAL(result);
4764 f = TP_RICHCOMPARE(type2);
4766 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4768 if (result != Py_NotImplemented) {
4769 Py_LeaveRecursiveCall();
4771 if (unlikely(result == NULL)) {
4772 return NUITKA_BOOL_EXCEPTION;
4776 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4782 Py_DECREF_IMMORTAL(result);
4788 cmpfunc fcmp = NULL;
4789 c = (*fcmp)(operand1, operand2);
4790 }
else if (PyInstance_Check(operand2)) {
4791 cmpfunc fcmp = type2->tp_compare;
4792 c = (*fcmp)(operand1, operand2);
4794 c = try_3way_compare(operand1, operand2);
4798 if (&PyBytes_Type == type2) {
4799 Py_uintptr_t aa = (Py_uintptr_t)operand1;
4800 Py_uintptr_t bb = (Py_uintptr_t)operand2;
4802 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4803 }
else if (operand1 == Py_None) {
4806 }
else if (operand2 == Py_None) {
4809 }
else if (PyNumber_Check(operand1)) {
4812 if (PyNumber_Check(operand2)) {
4814 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4815 Py_uintptr_t bb = (Py_uintptr_t)type2;
4817 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4821 }
else if (PyNumber_Check(operand2)) {
4825 int s = strcmp(
"bytes", type2->tp_name);
4833 Py_uintptr_t aa = (Py_uintptr_t)&PyBytes_Type;
4834 Py_uintptr_t bb = (Py_uintptr_t)type2;
4836 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
4841 Py_LeaveRecursiveCall();
4843 if (unlikely(c <= -2)) {
4844 return NUITKA_BOOL_EXCEPTION;
4869 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4873 bool checked_reverse_op =
false;
4876 if (&PyBytes_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyBytes_Type)) {
4877 f = TP_RICHCOMPARE(type2);
4880 checked_reverse_op =
true;
4882 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4884 if (result != Py_NotImplemented) {
4885 Py_LeaveRecursiveCall();
4887 if (unlikely(result == NULL)) {
4888 return NUITKA_BOOL_EXCEPTION;
4892 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4898 Py_DECREF_IMMORTAL(result);
4902 f = PyBytes_Type.tp_richcompare;
4905 PyObject *result = (*f)(operand1, operand2, Py_EQ);
4907 if (result != Py_NotImplemented) {
4908 Py_LeaveRecursiveCall();
4910 if (unlikely(result == NULL)) {
4911 return NUITKA_BOOL_EXCEPTION;
4915 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4921 Py_DECREF_IMMORTAL(result);
4924 if (checked_reverse_op ==
false) {
4925 f = TP_RICHCOMPARE(type2);
4928 PyObject *result = (*f)(operand2, operand1, Py_EQ);
4930 if (result != Py_NotImplemented) {
4931 Py_LeaveRecursiveCall();
4933 if (unlikely(result == NULL)) {
4934 return NUITKA_BOOL_EXCEPTION;
4938 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4944 Py_DECREF_IMMORTAL(result);
4948 Py_LeaveRecursiveCall();
4954 bool r = operand1 == operand2;
4955 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4960 bool r = operand1 != operand2;
4961 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
4966#if PYTHON_VERSION < 0x360
4967 PyErr_Format(PyExc_TypeError,
"unorderable types: bytes() == %s()", type2->tp_name);
4969 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'bytes' and '%s'", type2->tp_name);
4971 return NUITKA_BOOL_EXCEPTION;
4977#if PYTHON_VERSION < 0x300
4979PyObject *RICH_COMPARE_EQ_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
4981 if (Py_TYPE(operand1) == &PyInt_Type) {
4982 return COMPARE_EQ_OBJECT_INT_INT(operand1, operand2);
4985#if PYTHON_VERSION < 0x300
4986 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
4990 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
4995 PyTypeObject *type1 = Py_TYPE(operand1);
4997#if PYTHON_VERSION < 0x300
4999 if (type1 == &PyInt_Type && !0) {
5001 richcmpfunc frich = NULL;
5003 if (frich != NULL) {
5004 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
5006 if (result != Py_NotImplemented) {
5007 Py_LeaveRecursiveCall();
5012 Py_DECREF_IMMORTAL(result);
5016 cmpfunc fcmp = PyInt_Type.tp_compare;
5019 int c = (*fcmp)(operand1, operand2);
5020 c = adjust_tp_compare(c);
5022 Py_LeaveRecursiveCall();
5048 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5052 PyObject *result = BOOL_FROM(r);
5053 Py_INCREF_IMMORTAL(result);
5061 if (type1 != &PyInt_Type && 0) {
5065 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5067 if (result != Py_NotImplemented) {
5068 Py_LeaveRecursiveCall();
5073 Py_DECREF_IMMORTAL(result);
5077 f = TP_RICHCOMPARE(type1);
5079 PyObject *result = (*f)(operand1, operand2, Py_EQ);
5081 if (result != Py_NotImplemented) {
5082 Py_LeaveRecursiveCall();
5087 Py_DECREF_IMMORTAL(result);
5092 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5094 if (result != Py_NotImplemented) {
5095 Py_LeaveRecursiveCall();
5100 Py_DECREF_IMMORTAL(result);
5105 if (PyInstance_Check(operand1)) {
5106 cmpfunc fcmp = type1->tp_compare;
5107 c = (*fcmp)(operand1, operand2);
5109 cmpfunc fcmp = PyInt_Type.tp_compare;
5110 c = (*fcmp)(operand1, operand2);
5112 c = try_3way_compare(operand1, operand2);
5116 if (type1 == &PyInt_Type) {
5117 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5118 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5120 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5121 }
else if (operand1 == Py_None) {
5124 }
else if (operand2 == Py_None) {
5127 }
else if (PyNumber_Check(operand1)) {
5130 if (PyNumber_Check(operand2)) {
5132 Py_uintptr_t aa = (Py_uintptr_t)type1;
5133 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5135 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5139 }
else if (PyNumber_Check(operand2)) {
5143 int s = strcmp(type1->tp_name,
"int");
5151 Py_uintptr_t aa = (Py_uintptr_t)type1;
5152 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5154 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5159 Py_LeaveRecursiveCall();
5161 if (unlikely(c <= -2)) {
5187 PyObject *result = BOOL_FROM(r);
5188 Py_INCREF_IMMORTAL(result);
5191 bool checked_reverse_op =
false;
5194 if (type1 != &PyInt_Type && Nuitka_Type_IsSubtype(&PyInt_Type, type1)) {
5198 checked_reverse_op =
true;
5200 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5202 if (result != Py_NotImplemented) {
5203 Py_LeaveRecursiveCall();
5208 Py_DECREF_IMMORTAL(result);
5212 f = TP_RICHCOMPARE(type1);
5215 PyObject *result = (*f)(operand1, operand2, Py_EQ);
5217 if (result != Py_NotImplemented) {
5218 Py_LeaveRecursiveCall();
5223 Py_DECREF_IMMORTAL(result);
5226 if (checked_reverse_op ==
false) {
5230 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5232 if (result != Py_NotImplemented) {
5233 Py_LeaveRecursiveCall();
5238 Py_DECREF_IMMORTAL(result);
5242 Py_LeaveRecursiveCall();
5248 bool r = operand1 == operand2;
5249 PyObject *result = BOOL_FROM(r);
5250 Py_INCREF_IMMORTAL(result);
5254 bool r = operand1 != operand2;
5255 PyObject *result = BOOL_FROM(r);
5256 Py_INCREF_IMMORTAL(result);
5260#if PYTHON_VERSION < 0x360
5261 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == int()", type1->tp_name);
5263 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'int'", type1->tp_name);
5271#if PYTHON_VERSION < 0x300
5273PyObject *RICH_COMPARE_EQ_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
5275 if (&PyInt_Type == Py_TYPE(operand2)) {
5276 return COMPARE_EQ_OBJECT_INT_INT(operand1, operand2);
5279#if PYTHON_VERSION < 0x300
5280 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5284 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5289 PyTypeObject *type2 = Py_TYPE(operand2);
5291#if PYTHON_VERSION < 0x300
5293 if (&PyInt_Type == type2 && !0) {
5295 richcmpfunc frich = NULL;
5297 if (frich != NULL) {
5298 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
5300 if (result != Py_NotImplemented) {
5301 Py_LeaveRecursiveCall();
5306 Py_DECREF_IMMORTAL(result);
5310 cmpfunc fcmp = PyInt_Type.tp_compare;
5313 int c = (*fcmp)(operand1, operand2);
5314 c = adjust_tp_compare(c);
5316 Py_LeaveRecursiveCall();
5342 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5346 PyObject *result = BOOL_FROM(r);
5347 Py_INCREF_IMMORTAL(result);
5355 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5356 f = TP_RICHCOMPARE(type2);
5359 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5361 if (result != Py_NotImplemented) {
5362 Py_LeaveRecursiveCall();
5367 Py_DECREF_IMMORTAL(result);
5373 PyObject *result = (*f)(operand1, operand2, Py_EQ);
5375 if (result != Py_NotImplemented) {
5376 Py_LeaveRecursiveCall();
5381 Py_DECREF_IMMORTAL(result);
5384 f = TP_RICHCOMPARE(type2);
5386 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5388 if (result != Py_NotImplemented) {
5389 Py_LeaveRecursiveCall();
5394 Py_DECREF_IMMORTAL(result);
5400 cmpfunc fcmp = PyInt_Type.tp_compare;
5401 c = (*fcmp)(operand1, operand2);
5402 }
else if (PyInstance_Check(operand2)) {
5403 cmpfunc fcmp = type2->tp_compare;
5404 c = (*fcmp)(operand1, operand2);
5406 c = try_3way_compare(operand1, operand2);
5410 if (&PyInt_Type == type2) {
5411 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5412 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5414 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5415 }
else if (operand1 == Py_None) {
5418 }
else if (operand2 == Py_None) {
5421 }
else if (PyNumber_Check(operand1)) {
5424 if (PyNumber_Check(operand2)) {
5426 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5427 Py_uintptr_t bb = (Py_uintptr_t)type2;
5429 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5433 }
else if (PyNumber_Check(operand2)) {
5437 int s = strcmp(
"int", type2->tp_name);
5445 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
5446 Py_uintptr_t bb = (Py_uintptr_t)type2;
5448 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5453 Py_LeaveRecursiveCall();
5455 if (unlikely(c <= -2)) {
5481 PyObject *result = BOOL_FROM(r);
5482 Py_INCREF_IMMORTAL(result);
5485 bool checked_reverse_op =
false;
5488 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
5489 f = TP_RICHCOMPARE(type2);
5492 checked_reverse_op =
true;
5494 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5496 if (result != Py_NotImplemented) {
5497 Py_LeaveRecursiveCall();
5502 Py_DECREF_IMMORTAL(result);
5509 PyObject *result = (*f)(operand1, operand2, Py_EQ);
5511 if (result != Py_NotImplemented) {
5512 Py_LeaveRecursiveCall();
5517 Py_DECREF_IMMORTAL(result);
5520 if (checked_reverse_op ==
false) {
5521 f = TP_RICHCOMPARE(type2);
5524 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5526 if (result != Py_NotImplemented) {
5527 Py_LeaveRecursiveCall();
5532 Py_DECREF_IMMORTAL(result);
5536 Py_LeaveRecursiveCall();
5542 bool r = operand1 == operand2;
5543 PyObject *result = BOOL_FROM(r);
5544 Py_INCREF_IMMORTAL(result);
5548 bool r = operand1 != operand2;
5549 PyObject *result = BOOL_FROM(r);
5550 Py_INCREF_IMMORTAL(result);
5554#if PYTHON_VERSION < 0x360
5555 PyErr_Format(PyExc_TypeError,
"unorderable types: int() == %s()", type2->tp_name);
5557 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'int' and '%s'", type2->tp_name);
5565#if PYTHON_VERSION < 0x300
5567PyObject *RICH_COMPARE_EQ_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
5569 return COMPARE_EQ_OBJECT_INT_INT(operand1, operand2);
5573#if PYTHON_VERSION < 0x300
5575bool RICH_COMPARE_EQ_CBOOL_INT_INT(PyObject *operand1, PyObject *operand2) {
5577 return COMPARE_EQ_CBOOL_INT_INT(operand1, operand2);
5581#if PYTHON_VERSION < 0x300
5583nuitka_bool RICH_COMPARE_EQ_NBOOL_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
5585 if (Py_TYPE(operand1) == &PyInt_Type) {
5586 return COMPARE_EQ_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5589#if PYTHON_VERSION < 0x300
5590 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5591 return NUITKA_BOOL_EXCEPTION;
5594 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5595 return NUITKA_BOOL_EXCEPTION;
5599 PyTypeObject *type1 = Py_TYPE(operand1);
5601#if PYTHON_VERSION < 0x300
5603 if (type1 == &PyInt_Type && !0) {
5605 richcmpfunc frich = NULL;
5607 if (frich != NULL) {
5608 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
5610 if (result != Py_NotImplemented) {
5611 Py_LeaveRecursiveCall();
5613 if (unlikely(result == NULL)) {
5614 return NUITKA_BOOL_EXCEPTION;
5618 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5624 Py_DECREF_IMMORTAL(result);
5628 cmpfunc fcmp = PyInt_Type.tp_compare;
5631 int c = (*fcmp)(operand1, operand2);
5632 c = adjust_tp_compare(c);
5634 Py_LeaveRecursiveCall();
5637 return NUITKA_BOOL_EXCEPTION;
5660 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
5664 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5673 if (type1 != &PyInt_Type && 0) {
5677 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5679 if (result != Py_NotImplemented) {
5680 Py_LeaveRecursiveCall();
5682 if (unlikely(result == NULL)) {
5683 return NUITKA_BOOL_EXCEPTION;
5687 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5693 Py_DECREF_IMMORTAL(result);
5697 f = TP_RICHCOMPARE(type1);
5699 PyObject *result = (*f)(operand1, operand2, Py_EQ);
5701 if (result != Py_NotImplemented) {
5702 Py_LeaveRecursiveCall();
5704 if (unlikely(result == NULL)) {
5705 return NUITKA_BOOL_EXCEPTION;
5709 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5715 Py_DECREF_IMMORTAL(result);
5720 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5722 if (result != Py_NotImplemented) {
5723 Py_LeaveRecursiveCall();
5725 if (unlikely(result == NULL)) {
5726 return NUITKA_BOOL_EXCEPTION;
5730 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5736 Py_DECREF_IMMORTAL(result);
5741 if (PyInstance_Check(operand1)) {
5742 cmpfunc fcmp = type1->tp_compare;
5743 c = (*fcmp)(operand1, operand2);
5745 cmpfunc fcmp = PyInt_Type.tp_compare;
5746 c = (*fcmp)(operand1, operand2);
5748 c = try_3way_compare(operand1, operand2);
5752 if (type1 == &PyInt_Type) {
5753 Py_uintptr_t aa = (Py_uintptr_t)operand1;
5754 Py_uintptr_t bb = (Py_uintptr_t)operand2;
5756 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5757 }
else if (operand1 == Py_None) {
5760 }
else if (operand2 == Py_None) {
5763 }
else if (PyNumber_Check(operand1)) {
5766 if (PyNumber_Check(operand2)) {
5768 Py_uintptr_t aa = (Py_uintptr_t)type1;
5769 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5771 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5775 }
else if (PyNumber_Check(operand2)) {
5779 int s = strcmp(type1->tp_name,
"int");
5787 Py_uintptr_t aa = (Py_uintptr_t)type1;
5788 Py_uintptr_t bb = (Py_uintptr_t)&PyInt_Type;
5790 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
5795 Py_LeaveRecursiveCall();
5797 if (unlikely(c <= -2)) {
5798 return NUITKA_BOOL_EXCEPTION;
5823 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5827 bool checked_reverse_op =
false;
5830 if (type1 != &PyInt_Type && Nuitka_Type_IsSubtype(&PyInt_Type, type1)) {
5834 checked_reverse_op =
true;
5836 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5838 if (result != Py_NotImplemented) {
5839 Py_LeaveRecursiveCall();
5841 if (unlikely(result == NULL)) {
5842 return NUITKA_BOOL_EXCEPTION;
5846 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5852 Py_DECREF_IMMORTAL(result);
5856 f = TP_RICHCOMPARE(type1);
5859 PyObject *result = (*f)(operand1, operand2, Py_EQ);
5861 if (result != Py_NotImplemented) {
5862 Py_LeaveRecursiveCall();
5864 if (unlikely(result == NULL)) {
5865 return NUITKA_BOOL_EXCEPTION;
5869 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5875 Py_DECREF_IMMORTAL(result);
5878 if (checked_reverse_op ==
false) {
5882 PyObject *result = (*f)(operand2, operand1, Py_EQ);
5884 if (result != Py_NotImplemented) {
5885 Py_LeaveRecursiveCall();
5887 if (unlikely(result == NULL)) {
5888 return NUITKA_BOOL_EXCEPTION;
5892 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5898 Py_DECREF_IMMORTAL(result);
5902 Py_LeaveRecursiveCall();
5908 bool r = operand1 == operand2;
5909 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5914 bool r = operand1 != operand2;
5915 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5920#if PYTHON_VERSION < 0x360
5921 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == int()", type1->tp_name);
5923 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'int'", type1->tp_name);
5925 return NUITKA_BOOL_EXCEPTION;
5931#if PYTHON_VERSION < 0x300
5933nuitka_bool RICH_COMPARE_EQ_NBOOL_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
5935 if (&PyInt_Type == Py_TYPE(operand2)) {
5936 return COMPARE_EQ_CBOOL_INT_INT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5939#if PYTHON_VERSION < 0x300
5940 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
5941 return NUITKA_BOOL_EXCEPTION;
5944 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
5945 return NUITKA_BOOL_EXCEPTION;
5949 PyTypeObject *type2 = Py_TYPE(operand2);
5951#if PYTHON_VERSION < 0x300
5953 if (&PyInt_Type == type2 && !0) {
5955 richcmpfunc frich = NULL;
5957 if (frich != NULL) {
5958 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
5960 if (result != Py_NotImplemented) {
5961 Py_LeaveRecursiveCall();
5963 if (unlikely(result == NULL)) {
5964 return NUITKA_BOOL_EXCEPTION;
5968 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
5974 Py_DECREF_IMMORTAL(result);
5978 cmpfunc fcmp = PyInt_Type.tp_compare;
5981 int c = (*fcmp)(operand1, operand2);
5982 c = adjust_tp_compare(c);
5984 Py_LeaveRecursiveCall();
5987 return NUITKA_BOOL_EXCEPTION;
6010 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6014 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6023 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
6024 f = TP_RICHCOMPARE(type2);
6027 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6029 if (result != Py_NotImplemented) {
6030 Py_LeaveRecursiveCall();
6032 if (unlikely(result == NULL)) {
6033 return NUITKA_BOOL_EXCEPTION;
6037 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6043 Py_DECREF_IMMORTAL(result);
6049 PyObject *result = (*f)(operand1, operand2, Py_EQ);
6051 if (result != Py_NotImplemented) {
6052 Py_LeaveRecursiveCall();
6054 if (unlikely(result == NULL)) {
6055 return NUITKA_BOOL_EXCEPTION;
6059 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6065 Py_DECREF_IMMORTAL(result);
6068 f = TP_RICHCOMPARE(type2);
6070 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6072 if (result != Py_NotImplemented) {
6073 Py_LeaveRecursiveCall();
6075 if (unlikely(result == NULL)) {
6076 return NUITKA_BOOL_EXCEPTION;
6080 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6086 Py_DECREF_IMMORTAL(result);
6092 cmpfunc fcmp = PyInt_Type.tp_compare;
6093 c = (*fcmp)(operand1, operand2);
6094 }
else if (PyInstance_Check(operand2)) {
6095 cmpfunc fcmp = type2->tp_compare;
6096 c = (*fcmp)(operand1, operand2);
6098 c = try_3way_compare(operand1, operand2);
6102 if (&PyInt_Type == type2) {
6103 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6104 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6106 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6107 }
else if (operand1 == Py_None) {
6110 }
else if (operand2 == Py_None) {
6113 }
else if (PyNumber_Check(operand1)) {
6116 if (PyNumber_Check(operand2)) {
6118 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
6119 Py_uintptr_t bb = (Py_uintptr_t)type2;
6121 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6125 }
else if (PyNumber_Check(operand2)) {
6129 int s = strcmp(
"int", type2->tp_name);
6137 Py_uintptr_t aa = (Py_uintptr_t)&PyInt_Type;
6138 Py_uintptr_t bb = (Py_uintptr_t)type2;
6140 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6145 Py_LeaveRecursiveCall();
6147 if (unlikely(c <= -2)) {
6148 return NUITKA_BOOL_EXCEPTION;
6173 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6177 bool checked_reverse_op =
false;
6180 if (&PyInt_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
6181 f = TP_RICHCOMPARE(type2);
6184 checked_reverse_op =
true;
6186 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6188 if (result != Py_NotImplemented) {
6189 Py_LeaveRecursiveCall();
6191 if (unlikely(result == NULL)) {
6192 return NUITKA_BOOL_EXCEPTION;
6196 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6202 Py_DECREF_IMMORTAL(result);
6209 PyObject *result = (*f)(operand1, operand2, Py_EQ);
6211 if (result != Py_NotImplemented) {
6212 Py_LeaveRecursiveCall();
6214 if (unlikely(result == NULL)) {
6215 return NUITKA_BOOL_EXCEPTION;
6219 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6225 Py_DECREF_IMMORTAL(result);
6228 if (checked_reverse_op ==
false) {
6229 f = TP_RICHCOMPARE(type2);
6232 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6234 if (result != Py_NotImplemented) {
6235 Py_LeaveRecursiveCall();
6237 if (unlikely(result == NULL)) {
6238 return NUITKA_BOOL_EXCEPTION;
6242 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6248 Py_DECREF_IMMORTAL(result);
6252 Py_LeaveRecursiveCall();
6258 bool r = operand1 == operand2;
6259 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6264 bool r = operand1 != operand2;
6265 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6270#if PYTHON_VERSION < 0x360
6271 PyErr_Format(PyExc_TypeError,
"unorderable types: int() == %s()", type2->tp_name);
6273 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'int' and '%s'", type2->tp_name);
6275 return NUITKA_BOOL_EXCEPTION;
6281static PyObject *COMPARE_EQ_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6282 CHECK_OBJECT(operand1);
6283 assert(PyLong_CheckExact(operand1));
6284 CHECK_OBJECT(operand2);
6285 assert(PyLong_CheckExact(operand2));
6287 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
6289 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
6293 if (operand1_long_object == operand2_long_object) {
6295 }
else if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
6296 Nuitka_LongGetSignedDigitSize(operand2_long_object)) {
6299 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
6303 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] !=
6304 Nuitka_LongGetDigitPointer(operand2_long_object)[i]) {
6312 PyObject *result = BOOL_FROM(r);
6313 Py_INCREF_IMMORTAL(result);
6317PyObject *RICH_COMPARE_EQ_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
6319 if (Py_TYPE(operand1) == &PyLong_Type) {
6320 return COMPARE_EQ_OBJECT_LONG_LONG(operand1, operand2);
6323#if PYTHON_VERSION < 0x300
6324 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6328 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6333 PyTypeObject *type1 = Py_TYPE(operand1);
6335#if PYTHON_VERSION < 0x300
6337 if (type1 == &PyLong_Type && !0) {
6339 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6341 if (frich != NULL) {
6342 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
6344 if (result != Py_NotImplemented) {
6345 Py_LeaveRecursiveCall();
6350 Py_DECREF_IMMORTAL(result);
6354 cmpfunc fcmp = PyLong_Type.tp_compare;
6357 int c = (*fcmp)(operand1, operand2);
6358 c = adjust_tp_compare(c);
6360 Py_LeaveRecursiveCall();
6386 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6390 PyObject *result = BOOL_FROM(r);
6391 Py_INCREF_IMMORTAL(result);
6399 if (type1 != &PyLong_Type && 0) {
6400 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6403 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6405 if (result != Py_NotImplemented) {
6406 Py_LeaveRecursiveCall();
6411 Py_DECREF_IMMORTAL(result);
6415 f = TP_RICHCOMPARE(type1);
6417 PyObject *result = (*f)(operand1, operand2, Py_EQ);
6419 if (result != Py_NotImplemented) {
6420 Py_LeaveRecursiveCall();
6425 Py_DECREF_IMMORTAL(result);
6428 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6430 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6432 if (result != Py_NotImplemented) {
6433 Py_LeaveRecursiveCall();
6438 Py_DECREF_IMMORTAL(result);
6443 if (PyInstance_Check(operand1)) {
6444 cmpfunc fcmp = type1->tp_compare;
6445 c = (*fcmp)(operand1, operand2);
6447 cmpfunc fcmp = PyLong_Type.tp_compare;
6448 c = (*fcmp)(operand1, operand2);
6450 c = try_3way_compare(operand1, operand2);
6454 if (type1 == &PyLong_Type) {
6455 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6456 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6458 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6459 }
else if (operand1 == Py_None) {
6462 }
else if (operand2 == Py_None) {
6465 }
else if (PyNumber_Check(operand1)) {
6468 if (PyNumber_Check(operand2)) {
6470 Py_uintptr_t aa = (Py_uintptr_t)type1;
6471 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6473 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6477 }
else if (PyNumber_Check(operand2)) {
6481 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"long" :
"int"));
6489 Py_uintptr_t aa = (Py_uintptr_t)type1;
6490 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
6492 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6497 Py_LeaveRecursiveCall();
6499 if (unlikely(c <= -2)) {
6525 PyObject *result = BOOL_FROM(r);
6526 Py_INCREF_IMMORTAL(result);
6529 bool checked_reverse_op =
false;
6532 if (type1 != &PyLong_Type && Nuitka_Type_IsSubtype(&PyLong_Type, type1)) {
6533 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6536 checked_reverse_op =
true;
6538 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6540 if (result != Py_NotImplemented) {
6541 Py_LeaveRecursiveCall();
6546 Py_DECREF_IMMORTAL(result);
6550 f = TP_RICHCOMPARE(type1);
6553 PyObject *result = (*f)(operand1, operand2, Py_EQ);
6555 if (result != Py_NotImplemented) {
6556 Py_LeaveRecursiveCall();
6561 Py_DECREF_IMMORTAL(result);
6564 if (checked_reverse_op ==
false) {
6565 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6568 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6570 if (result != Py_NotImplemented) {
6571 Py_LeaveRecursiveCall();
6576 Py_DECREF_IMMORTAL(result);
6580 Py_LeaveRecursiveCall();
6586 bool r = operand1 == operand2;
6587 PyObject *result = BOOL_FROM(r);
6588 Py_INCREF_IMMORTAL(result);
6592 bool r = operand1 != operand2;
6593 PyObject *result = BOOL_FROM(r);
6594 Py_INCREF_IMMORTAL(result);
6598#if PYTHON_VERSION < 0x300
6599 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == long()", type1->tp_name);
6600#elif PYTHON_VERSION < 0x360
6601 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == int()", type1->tp_name);
6603 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'int'", type1->tp_name);
6611PyObject *RICH_COMPARE_EQ_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
6613 if (&PyLong_Type == Py_TYPE(operand2)) {
6614 return COMPARE_EQ_OBJECT_LONG_LONG(operand1, operand2);
6617#if PYTHON_VERSION < 0x300
6618 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6622 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6627 PyTypeObject *type2 = Py_TYPE(operand2);
6629#if PYTHON_VERSION < 0x300
6631 if (&PyLong_Type == type2 && !0) {
6633 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6635 if (frich != NULL) {
6636 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
6638 if (result != Py_NotImplemented) {
6639 Py_LeaveRecursiveCall();
6644 Py_DECREF_IMMORTAL(result);
6648 cmpfunc fcmp = PyLong_Type.tp_compare;
6651 int c = (*fcmp)(operand1, operand2);
6652 c = adjust_tp_compare(c);
6654 Py_LeaveRecursiveCall();
6680 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
6684 PyObject *result = BOOL_FROM(r);
6685 Py_INCREF_IMMORTAL(result);
6693 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
6694 f = TP_RICHCOMPARE(type2);
6697 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6699 if (result != Py_NotImplemented) {
6700 Py_LeaveRecursiveCall();
6705 Py_DECREF_IMMORTAL(result);
6709 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6711 PyObject *result = (*f)(operand1, operand2, Py_EQ);
6713 if (result != Py_NotImplemented) {
6714 Py_LeaveRecursiveCall();
6719 Py_DECREF_IMMORTAL(result);
6722 f = TP_RICHCOMPARE(type2);
6724 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6726 if (result != Py_NotImplemented) {
6727 Py_LeaveRecursiveCall();
6732 Py_DECREF_IMMORTAL(result);
6738 cmpfunc fcmp = PyLong_Type.tp_compare;
6739 c = (*fcmp)(operand1, operand2);
6740 }
else if (PyInstance_Check(operand2)) {
6741 cmpfunc fcmp = type2->tp_compare;
6742 c = (*fcmp)(operand1, operand2);
6744 c = try_3way_compare(operand1, operand2);
6748 if (&PyLong_Type == type2) {
6749 Py_uintptr_t aa = (Py_uintptr_t)operand1;
6750 Py_uintptr_t bb = (Py_uintptr_t)operand2;
6752 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6753 }
else if (operand1 == Py_None) {
6756 }
else if (operand2 == Py_None) {
6759 }
else if (PyNumber_Check(operand1)) {
6762 if (PyNumber_Check(operand2)) {
6764 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
6765 Py_uintptr_t bb = (Py_uintptr_t)type2;
6767 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6771 }
else if (PyNumber_Check(operand2)) {
6775 int s = strcmp((PYTHON_VERSION < 0x300 ?
"long" :
"int"), type2->tp_name);
6783 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
6784 Py_uintptr_t bb = (Py_uintptr_t)type2;
6786 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
6791 Py_LeaveRecursiveCall();
6793 if (unlikely(c <= -2)) {
6819 PyObject *result = BOOL_FROM(r);
6820 Py_INCREF_IMMORTAL(result);
6823 bool checked_reverse_op =
false;
6826 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
6827 f = TP_RICHCOMPARE(type2);
6830 checked_reverse_op =
true;
6832 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6834 if (result != Py_NotImplemented) {
6835 Py_LeaveRecursiveCall();
6840 Py_DECREF_IMMORTAL(result);
6844 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6847 PyObject *result = (*f)(operand1, operand2, Py_EQ);
6849 if (result != Py_NotImplemented) {
6850 Py_LeaveRecursiveCall();
6855 Py_DECREF_IMMORTAL(result);
6858 if (checked_reverse_op ==
false) {
6859 f = TP_RICHCOMPARE(type2);
6862 PyObject *result = (*f)(operand2, operand1, Py_EQ);
6864 if (result != Py_NotImplemented) {
6865 Py_LeaveRecursiveCall();
6870 Py_DECREF_IMMORTAL(result);
6874 Py_LeaveRecursiveCall();
6880 bool r = operand1 == operand2;
6881 PyObject *result = BOOL_FROM(r);
6882 Py_INCREF_IMMORTAL(result);
6886 bool r = operand1 != operand2;
6887 PyObject *result = BOOL_FROM(r);
6888 Py_INCREF_IMMORTAL(result);
6892#if PYTHON_VERSION < 0x300
6893 PyErr_Format(PyExc_TypeError,
"unorderable types: long() == %s()", type2->tp_name);
6894#elif PYTHON_VERSION < 0x360
6895 PyErr_Format(PyExc_TypeError,
"unorderable types: int() == %s()", type2->tp_name);
6897 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'int' and '%s'", type2->tp_name);
6905PyObject *RICH_COMPARE_EQ_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6907 return COMPARE_EQ_OBJECT_LONG_LONG(operand1, operand2);
6910static bool COMPARE_EQ_CBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6911 CHECK_OBJECT(operand1);
6912 assert(PyLong_CheckExact(operand1));
6913 CHECK_OBJECT(operand2);
6914 assert(PyLong_CheckExact(operand2));
6916 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
6918 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
6922 if (operand1_long_object == operand2_long_object) {
6924 }
else if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
6925 Nuitka_LongGetSignedDigitSize(operand2_long_object)) {
6928 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
6932 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] !=
6933 Nuitka_LongGetDigitPointer(operand2_long_object)[i]) {
6946bool RICH_COMPARE_EQ_CBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
6948 return COMPARE_EQ_CBOOL_LONG_LONG(operand1, operand2);
6952nuitka_bool RICH_COMPARE_EQ_NBOOL_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
6954 if (Py_TYPE(operand1) == &PyLong_Type) {
6955 return COMPARE_EQ_CBOOL_LONG_LONG(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6958#if PYTHON_VERSION < 0x300
6959 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
6960 return NUITKA_BOOL_EXCEPTION;
6963 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
6964 return NUITKA_BOOL_EXCEPTION;
6968 PyTypeObject *type1 = Py_TYPE(operand1);
6970#if PYTHON_VERSION < 0x300
6972 if (type1 == &PyLong_Type && !0) {
6974 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
6976 if (frich != NULL) {
6977 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
6979 if (result != Py_NotImplemented) {
6980 Py_LeaveRecursiveCall();
6982 if (unlikely(result == NULL)) {
6983 return NUITKA_BOOL_EXCEPTION;
6987 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6993 Py_DECREF_IMMORTAL(result);
6997 cmpfunc fcmp = PyLong_Type.tp_compare;
7000 int c = (*fcmp)(operand1, operand2);
7001 c = adjust_tp_compare(c);
7003 Py_LeaveRecursiveCall();
7006 return NUITKA_BOOL_EXCEPTION;
7029 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7033 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7042 if (type1 != &PyLong_Type && 0) {
7043 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7046 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7048 if (result != Py_NotImplemented) {
7049 Py_LeaveRecursiveCall();
7051 if (unlikely(result == NULL)) {
7052 return NUITKA_BOOL_EXCEPTION;
7056 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7062 Py_DECREF_IMMORTAL(result);
7066 f = TP_RICHCOMPARE(type1);
7068 PyObject *result = (*f)(operand1, operand2, Py_EQ);
7070 if (result != Py_NotImplemented) {
7071 Py_LeaveRecursiveCall();
7073 if (unlikely(result == NULL)) {
7074 return NUITKA_BOOL_EXCEPTION;
7078 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7084 Py_DECREF_IMMORTAL(result);
7087 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7089 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7091 if (result != Py_NotImplemented) {
7092 Py_LeaveRecursiveCall();
7094 if (unlikely(result == NULL)) {
7095 return NUITKA_BOOL_EXCEPTION;
7099 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7105 Py_DECREF_IMMORTAL(result);
7110 if (PyInstance_Check(operand1)) {
7111 cmpfunc fcmp = type1->tp_compare;
7112 c = (*fcmp)(operand1, operand2);
7114 cmpfunc fcmp = PyLong_Type.tp_compare;
7115 c = (*fcmp)(operand1, operand2);
7117 c = try_3way_compare(operand1, operand2);
7121 if (type1 == &PyLong_Type) {
7122 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7123 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7125 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7126 }
else if (operand1 == Py_None) {
7129 }
else if (operand2 == Py_None) {
7132 }
else if (PyNumber_Check(operand1)) {
7135 if (PyNumber_Check(operand2)) {
7137 Py_uintptr_t aa = (Py_uintptr_t)type1;
7138 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
7140 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7144 }
else if (PyNumber_Check(operand2)) {
7148 int s = strcmp(type1->tp_name, (PYTHON_VERSION < 0x300 ?
"long" :
"int"));
7156 Py_uintptr_t aa = (Py_uintptr_t)type1;
7157 Py_uintptr_t bb = (Py_uintptr_t)&PyLong_Type;
7159 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7164 Py_LeaveRecursiveCall();
7166 if (unlikely(c <= -2)) {
7167 return NUITKA_BOOL_EXCEPTION;
7192 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7196 bool checked_reverse_op =
false;
7199 if (type1 != &PyLong_Type && Nuitka_Type_IsSubtype(&PyLong_Type, type1)) {
7200 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7203 checked_reverse_op =
true;
7205 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7207 if (result != Py_NotImplemented) {
7208 Py_LeaveRecursiveCall();
7210 if (unlikely(result == NULL)) {
7211 return NUITKA_BOOL_EXCEPTION;
7215 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7221 Py_DECREF_IMMORTAL(result);
7225 f = TP_RICHCOMPARE(type1);
7228 PyObject *result = (*f)(operand1, operand2, Py_EQ);
7230 if (result != Py_NotImplemented) {
7231 Py_LeaveRecursiveCall();
7233 if (unlikely(result == NULL)) {
7234 return NUITKA_BOOL_EXCEPTION;
7238 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7244 Py_DECREF_IMMORTAL(result);
7247 if (checked_reverse_op ==
false) {
7248 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7251 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7253 if (result != Py_NotImplemented) {
7254 Py_LeaveRecursiveCall();
7256 if (unlikely(result == NULL)) {
7257 return NUITKA_BOOL_EXCEPTION;
7261 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7267 Py_DECREF_IMMORTAL(result);
7271 Py_LeaveRecursiveCall();
7277 bool r = operand1 == operand2;
7278 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7283 bool r = operand1 != operand2;
7284 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7289#if PYTHON_VERSION < 0x300
7290 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == long()", type1->tp_name);
7291#elif PYTHON_VERSION < 0x360
7292 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == int()", type1->tp_name);
7294 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'int'", type1->tp_name);
7296 return NUITKA_BOOL_EXCEPTION;
7302nuitka_bool RICH_COMPARE_EQ_NBOOL_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
7304 if (&PyLong_Type == Py_TYPE(operand2)) {
7305 return COMPARE_EQ_CBOOL_LONG_LONG(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7308#if PYTHON_VERSION < 0x300
7309 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7310 return NUITKA_BOOL_EXCEPTION;
7313 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7314 return NUITKA_BOOL_EXCEPTION;
7318 PyTypeObject *type2 = Py_TYPE(operand2);
7320#if PYTHON_VERSION < 0x300
7322 if (&PyLong_Type == type2 && !0) {
7324 richcmpfunc frich = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7326 if (frich != NULL) {
7327 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
7329 if (result != Py_NotImplemented) {
7330 Py_LeaveRecursiveCall();
7332 if (unlikely(result == NULL)) {
7333 return NUITKA_BOOL_EXCEPTION;
7337 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7343 Py_DECREF_IMMORTAL(result);
7347 cmpfunc fcmp = PyLong_Type.tp_compare;
7350 int c = (*fcmp)(operand1, operand2);
7351 c = adjust_tp_compare(c);
7353 Py_LeaveRecursiveCall();
7356 return NUITKA_BOOL_EXCEPTION;
7379 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7383 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7392 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
7393 f = TP_RICHCOMPARE(type2);
7396 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7398 if (result != Py_NotImplemented) {
7399 Py_LeaveRecursiveCall();
7401 if (unlikely(result == NULL)) {
7402 return NUITKA_BOOL_EXCEPTION;
7406 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7412 Py_DECREF_IMMORTAL(result);
7416 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7418 PyObject *result = (*f)(operand1, operand2, Py_EQ);
7420 if (result != Py_NotImplemented) {
7421 Py_LeaveRecursiveCall();
7423 if (unlikely(result == NULL)) {
7424 return NUITKA_BOOL_EXCEPTION;
7428 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7434 Py_DECREF_IMMORTAL(result);
7437 f = TP_RICHCOMPARE(type2);
7439 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7441 if (result != Py_NotImplemented) {
7442 Py_LeaveRecursiveCall();
7444 if (unlikely(result == NULL)) {
7445 return NUITKA_BOOL_EXCEPTION;
7449 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7455 Py_DECREF_IMMORTAL(result);
7461 cmpfunc fcmp = PyLong_Type.tp_compare;
7462 c = (*fcmp)(operand1, operand2);
7463 }
else if (PyInstance_Check(operand2)) {
7464 cmpfunc fcmp = type2->tp_compare;
7465 c = (*fcmp)(operand1, operand2);
7467 c = try_3way_compare(operand1, operand2);
7471 if (&PyLong_Type == type2) {
7472 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7473 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7475 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7476 }
else if (operand1 == Py_None) {
7479 }
else if (operand2 == Py_None) {
7482 }
else if (PyNumber_Check(operand1)) {
7485 if (PyNumber_Check(operand2)) {
7487 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
7488 Py_uintptr_t bb = (Py_uintptr_t)type2;
7490 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7494 }
else if (PyNumber_Check(operand2)) {
7498 int s = strcmp((PYTHON_VERSION < 0x300 ?
"long" :
"int"), type2->tp_name);
7506 Py_uintptr_t aa = (Py_uintptr_t)&PyLong_Type;
7507 Py_uintptr_t bb = (Py_uintptr_t)type2;
7509 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7514 Py_LeaveRecursiveCall();
7516 if (unlikely(c <= -2)) {
7517 return NUITKA_BOOL_EXCEPTION;
7542 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7546 bool checked_reverse_op =
false;
7549 if (&PyLong_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
7550 f = TP_RICHCOMPARE(type2);
7553 checked_reverse_op =
true;
7555 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7557 if (result != Py_NotImplemented) {
7558 Py_LeaveRecursiveCall();
7560 if (unlikely(result == NULL)) {
7561 return NUITKA_BOOL_EXCEPTION;
7565 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7571 Py_DECREF_IMMORTAL(result);
7575 f = (PYTHON_VERSION < 0x300 ? NULL : PyLong_Type.tp_richcompare);
7578 PyObject *result = (*f)(operand1, operand2, Py_EQ);
7580 if (result != Py_NotImplemented) {
7581 Py_LeaveRecursiveCall();
7583 if (unlikely(result == NULL)) {
7584 return NUITKA_BOOL_EXCEPTION;
7588 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7594 Py_DECREF_IMMORTAL(result);
7597 if (checked_reverse_op ==
false) {
7598 f = TP_RICHCOMPARE(type2);
7601 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7603 if (result != Py_NotImplemented) {
7604 Py_LeaveRecursiveCall();
7606 if (unlikely(result == NULL)) {
7607 return NUITKA_BOOL_EXCEPTION;
7611 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7617 Py_DECREF_IMMORTAL(result);
7621 Py_LeaveRecursiveCall();
7627 bool r = operand1 == operand2;
7628 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7633 bool r = operand1 != operand2;
7634 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
7639#if PYTHON_VERSION < 0x300
7640 PyErr_Format(PyExc_TypeError,
"unorderable types: long() == %s()", type2->tp_name);
7641#elif PYTHON_VERSION < 0x360
7642 PyErr_Format(PyExc_TypeError,
"unorderable types: int() == %s()", type2->tp_name);
7644 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'int' and '%s'", type2->tp_name);
7646 return NUITKA_BOOL_EXCEPTION;
7651static PyObject *COMPARE_EQ_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
7652 CHECK_OBJECT(operand1);
7653 assert(PyFloat_CheckExact(operand1));
7654 CHECK_OBJECT(operand2);
7655 assert(PyFloat_CheckExact(operand2));
7657 const double a = PyFloat_AS_DOUBLE(operand1);
7658 const double b = PyFloat_AS_DOUBLE(operand2);
7663 PyObject *result = BOOL_FROM(r);
7664 Py_INCREF_IMMORTAL(result);
7668PyObject *RICH_COMPARE_EQ_OBJECT_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
7670 if (Py_TYPE(operand1) == &PyFloat_Type) {
7671 return COMPARE_EQ_OBJECT_FLOAT_FLOAT(operand1, operand2);
7674#if PYTHON_VERSION < 0x300
7675 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7679 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7684 PyTypeObject *type1 = Py_TYPE(operand1);
7686#if PYTHON_VERSION < 0x300
7688 if (type1 == &PyFloat_Type && !0) {
7690 richcmpfunc frich = PyFloat_Type.tp_richcompare;
7692 if (frich != NULL) {
7693 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
7695 if (result != Py_NotImplemented) {
7696 Py_LeaveRecursiveCall();
7701 Py_DECREF_IMMORTAL(result);
7705 cmpfunc fcmp = NULL;
7708 int c = (*fcmp)(operand1, operand2);
7709 c = adjust_tp_compare(c);
7711 Py_LeaveRecursiveCall();
7737 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
7741 PyObject *result = BOOL_FROM(r);
7742 Py_INCREF_IMMORTAL(result);
7750 if (type1 != &PyFloat_Type && 0) {
7751 f = PyFloat_Type.tp_richcompare;
7754 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7756 if (result != Py_NotImplemented) {
7757 Py_LeaveRecursiveCall();
7762 Py_DECREF_IMMORTAL(result);
7766 f = TP_RICHCOMPARE(type1);
7768 PyObject *result = (*f)(operand1, operand2, Py_EQ);
7770 if (result != Py_NotImplemented) {
7771 Py_LeaveRecursiveCall();
7776 Py_DECREF_IMMORTAL(result);
7779 f = PyFloat_Type.tp_richcompare;
7781 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7783 if (result != Py_NotImplemented) {
7784 Py_LeaveRecursiveCall();
7789 Py_DECREF_IMMORTAL(result);
7794 if (PyInstance_Check(operand1)) {
7795 cmpfunc fcmp = type1->tp_compare;
7796 c = (*fcmp)(operand1, operand2);
7798 cmpfunc fcmp = NULL;
7799 c = (*fcmp)(operand1, operand2);
7801 c = try_3way_compare(operand1, operand2);
7805 if (type1 == &PyFloat_Type) {
7806 Py_uintptr_t aa = (Py_uintptr_t)operand1;
7807 Py_uintptr_t bb = (Py_uintptr_t)operand2;
7809 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7810 }
else if (operand1 == Py_None) {
7813 }
else if (operand2 == Py_None) {
7816 }
else if (PyNumber_Check(operand1)) {
7819 if (PyNumber_Check(operand2)) {
7821 Py_uintptr_t aa = (Py_uintptr_t)type1;
7822 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
7824 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7828 }
else if (PyNumber_Check(operand2)) {
7832 int s = strcmp(type1->tp_name,
"float");
7840 Py_uintptr_t aa = (Py_uintptr_t)type1;
7841 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
7843 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
7848 Py_LeaveRecursiveCall();
7850 if (unlikely(c <= -2)) {
7876 PyObject *result = BOOL_FROM(r);
7877 Py_INCREF_IMMORTAL(result);
7880 bool checked_reverse_op =
false;
7883 if (type1 != &PyFloat_Type && Nuitka_Type_IsSubtype(&PyFloat_Type, type1)) {
7884 f = PyFloat_Type.tp_richcompare;
7887 checked_reverse_op =
true;
7889 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7891 if (result != Py_NotImplemented) {
7892 Py_LeaveRecursiveCall();
7897 Py_DECREF_IMMORTAL(result);
7901 f = TP_RICHCOMPARE(type1);
7904 PyObject *result = (*f)(operand1, operand2, Py_EQ);
7906 if (result != Py_NotImplemented) {
7907 Py_LeaveRecursiveCall();
7912 Py_DECREF_IMMORTAL(result);
7915 if (checked_reverse_op ==
false) {
7916 f = PyFloat_Type.tp_richcompare;
7919 PyObject *result = (*f)(operand2, operand1, Py_EQ);
7921 if (result != Py_NotImplemented) {
7922 Py_LeaveRecursiveCall();
7927 Py_DECREF_IMMORTAL(result);
7931 Py_LeaveRecursiveCall();
7937 bool r = operand1 == operand2;
7938 PyObject *result = BOOL_FROM(r);
7939 Py_INCREF_IMMORTAL(result);
7943 bool r = operand1 != operand2;
7944 PyObject *result = BOOL_FROM(r);
7945 Py_INCREF_IMMORTAL(result);
7949#if PYTHON_VERSION < 0x360
7950 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == float()", type1->tp_name);
7952 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'float'", type1->tp_name);
7960PyObject *RICH_COMPARE_EQ_OBJECT_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
7962 if (&PyFloat_Type == Py_TYPE(operand2)) {
7963 return COMPARE_EQ_OBJECT_FLOAT_FLOAT(operand1, operand2);
7966#if PYTHON_VERSION < 0x300
7967 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
7971 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
7976 PyTypeObject *type2 = Py_TYPE(operand2);
7978#if PYTHON_VERSION < 0x300
7980 if (&PyFloat_Type == type2 && !0) {
7982 richcmpfunc frich = PyFloat_Type.tp_richcompare;
7984 if (frich != NULL) {
7985 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
7987 if (result != Py_NotImplemented) {
7988 Py_LeaveRecursiveCall();
7993 Py_DECREF_IMMORTAL(result);
7997 cmpfunc fcmp = NULL;
8000 int c = (*fcmp)(operand1, operand2);
8001 c = adjust_tp_compare(c);
8003 Py_LeaveRecursiveCall();
8029 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8033 PyObject *result = BOOL_FROM(r);
8034 Py_INCREF_IMMORTAL(result);
8042 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8043 f = TP_RICHCOMPARE(type2);
8046 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8048 if (result != Py_NotImplemented) {
8049 Py_LeaveRecursiveCall();
8054 Py_DECREF_IMMORTAL(result);
8058 f = PyFloat_Type.tp_richcompare;
8060 PyObject *result = (*f)(operand1, operand2, Py_EQ);
8062 if (result != Py_NotImplemented) {
8063 Py_LeaveRecursiveCall();
8068 Py_DECREF_IMMORTAL(result);
8071 f = TP_RICHCOMPARE(type2);
8073 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8075 if (result != Py_NotImplemented) {
8076 Py_LeaveRecursiveCall();
8081 Py_DECREF_IMMORTAL(result);
8087 cmpfunc fcmp = NULL;
8088 c = (*fcmp)(operand1, operand2);
8089 }
else if (PyInstance_Check(operand2)) {
8090 cmpfunc fcmp = type2->tp_compare;
8091 c = (*fcmp)(operand1, operand2);
8093 c = try_3way_compare(operand1, operand2);
8097 if (&PyFloat_Type == type2) {
8098 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8099 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8101 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8102 }
else if (operand1 == Py_None) {
8105 }
else if (operand2 == Py_None) {
8108 }
else if (PyNumber_Check(operand1)) {
8111 if (PyNumber_Check(operand2)) {
8113 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8114 Py_uintptr_t bb = (Py_uintptr_t)type2;
8116 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8120 }
else if (PyNumber_Check(operand2)) {
8124 int s = strcmp(
"float", type2->tp_name);
8132 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8133 Py_uintptr_t bb = (Py_uintptr_t)type2;
8135 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8140 Py_LeaveRecursiveCall();
8142 if (unlikely(c <= -2)) {
8168 PyObject *result = BOOL_FROM(r);
8169 Py_INCREF_IMMORTAL(result);
8172 bool checked_reverse_op =
false;
8175 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8176 f = TP_RICHCOMPARE(type2);
8179 checked_reverse_op =
true;
8181 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8183 if (result != Py_NotImplemented) {
8184 Py_LeaveRecursiveCall();
8189 Py_DECREF_IMMORTAL(result);
8193 f = PyFloat_Type.tp_richcompare;
8196 PyObject *result = (*f)(operand1, operand2, Py_EQ);
8198 if (result != Py_NotImplemented) {
8199 Py_LeaveRecursiveCall();
8204 Py_DECREF_IMMORTAL(result);
8207 if (checked_reverse_op ==
false) {
8208 f = TP_RICHCOMPARE(type2);
8211 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8213 if (result != Py_NotImplemented) {
8214 Py_LeaveRecursiveCall();
8219 Py_DECREF_IMMORTAL(result);
8223 Py_LeaveRecursiveCall();
8229 bool r = operand1 == operand2;
8230 PyObject *result = BOOL_FROM(r);
8231 Py_INCREF_IMMORTAL(result);
8235 bool r = operand1 != operand2;
8236 PyObject *result = BOOL_FROM(r);
8237 Py_INCREF_IMMORTAL(result);
8241#if PYTHON_VERSION < 0x360
8242 PyErr_Format(PyExc_TypeError,
"unorderable types: float() == %s()", type2->tp_name);
8244 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'float' and '%s'", type2->tp_name);
8252PyObject *RICH_COMPARE_EQ_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8254 return COMPARE_EQ_OBJECT_FLOAT_FLOAT(operand1, operand2);
8257static bool COMPARE_EQ_CBOOL_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8258 CHECK_OBJECT(operand1);
8259 assert(PyFloat_CheckExact(operand1));
8260 CHECK_OBJECT(operand2);
8261 assert(PyFloat_CheckExact(operand2));
8263 const double a = PyFloat_AS_DOUBLE(operand1);
8264 const double b = PyFloat_AS_DOUBLE(operand2);
8274bool RICH_COMPARE_EQ_CBOOL_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
8276 return COMPARE_EQ_CBOOL_FLOAT_FLOAT(operand1, operand2);
8280nuitka_bool RICH_COMPARE_EQ_NBOOL_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
8282 if (Py_TYPE(operand1) == &PyFloat_Type) {
8283 return COMPARE_EQ_CBOOL_FLOAT_FLOAT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8286#if PYTHON_VERSION < 0x300
8287 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8288 return NUITKA_BOOL_EXCEPTION;
8291 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8292 return NUITKA_BOOL_EXCEPTION;
8296 PyTypeObject *type1 = Py_TYPE(operand1);
8298#if PYTHON_VERSION < 0x300
8300 if (type1 == &PyFloat_Type && !0) {
8302 richcmpfunc frich = PyFloat_Type.tp_richcompare;
8304 if (frich != NULL) {
8305 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
8307 if (result != Py_NotImplemented) {
8308 Py_LeaveRecursiveCall();
8310 if (unlikely(result == NULL)) {
8311 return NUITKA_BOOL_EXCEPTION;
8315 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8321 Py_DECREF_IMMORTAL(result);
8325 cmpfunc fcmp = NULL;
8328 int c = (*fcmp)(operand1, operand2);
8329 c = adjust_tp_compare(c);
8331 Py_LeaveRecursiveCall();
8334 return NUITKA_BOOL_EXCEPTION;
8357 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8361 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8370 if (type1 != &PyFloat_Type && 0) {
8371 f = PyFloat_Type.tp_richcompare;
8374 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8376 if (result != Py_NotImplemented) {
8377 Py_LeaveRecursiveCall();
8379 if (unlikely(result == NULL)) {
8380 return NUITKA_BOOL_EXCEPTION;
8384 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8390 Py_DECREF_IMMORTAL(result);
8394 f = TP_RICHCOMPARE(type1);
8396 PyObject *result = (*f)(operand1, operand2, Py_EQ);
8398 if (result != Py_NotImplemented) {
8399 Py_LeaveRecursiveCall();
8401 if (unlikely(result == NULL)) {
8402 return NUITKA_BOOL_EXCEPTION;
8406 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8412 Py_DECREF_IMMORTAL(result);
8415 f = PyFloat_Type.tp_richcompare;
8417 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8419 if (result != Py_NotImplemented) {
8420 Py_LeaveRecursiveCall();
8422 if (unlikely(result == NULL)) {
8423 return NUITKA_BOOL_EXCEPTION;
8427 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8433 Py_DECREF_IMMORTAL(result);
8438 if (PyInstance_Check(operand1)) {
8439 cmpfunc fcmp = type1->tp_compare;
8440 c = (*fcmp)(operand1, operand2);
8442 cmpfunc fcmp = NULL;
8443 c = (*fcmp)(operand1, operand2);
8445 c = try_3way_compare(operand1, operand2);
8449 if (type1 == &PyFloat_Type) {
8450 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8451 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8453 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8454 }
else if (operand1 == Py_None) {
8457 }
else if (operand2 == Py_None) {
8460 }
else if (PyNumber_Check(operand1)) {
8463 if (PyNumber_Check(operand2)) {
8465 Py_uintptr_t aa = (Py_uintptr_t)type1;
8466 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
8468 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8472 }
else if (PyNumber_Check(operand2)) {
8476 int s = strcmp(type1->tp_name,
"float");
8484 Py_uintptr_t aa = (Py_uintptr_t)type1;
8485 Py_uintptr_t bb = (Py_uintptr_t)&PyFloat_Type;
8487 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8492 Py_LeaveRecursiveCall();
8494 if (unlikely(c <= -2)) {
8495 return NUITKA_BOOL_EXCEPTION;
8520 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8524 bool checked_reverse_op =
false;
8527 if (type1 != &PyFloat_Type && Nuitka_Type_IsSubtype(&PyFloat_Type, type1)) {
8528 f = PyFloat_Type.tp_richcompare;
8531 checked_reverse_op =
true;
8533 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8535 if (result != Py_NotImplemented) {
8536 Py_LeaveRecursiveCall();
8538 if (unlikely(result == NULL)) {
8539 return NUITKA_BOOL_EXCEPTION;
8543 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8549 Py_DECREF_IMMORTAL(result);
8553 f = TP_RICHCOMPARE(type1);
8556 PyObject *result = (*f)(operand1, operand2, Py_EQ);
8558 if (result != Py_NotImplemented) {
8559 Py_LeaveRecursiveCall();
8561 if (unlikely(result == NULL)) {
8562 return NUITKA_BOOL_EXCEPTION;
8566 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8572 Py_DECREF_IMMORTAL(result);
8575 if (checked_reverse_op ==
false) {
8576 f = PyFloat_Type.tp_richcompare;
8579 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8581 if (result != Py_NotImplemented) {
8582 Py_LeaveRecursiveCall();
8584 if (unlikely(result == NULL)) {
8585 return NUITKA_BOOL_EXCEPTION;
8589 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8595 Py_DECREF_IMMORTAL(result);
8599 Py_LeaveRecursiveCall();
8605 bool r = operand1 == operand2;
8606 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8611 bool r = operand1 != operand2;
8612 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8617#if PYTHON_VERSION < 0x360
8618 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == float()", type1->tp_name);
8620 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'float'", type1->tp_name);
8622 return NUITKA_BOOL_EXCEPTION;
8628nuitka_bool RICH_COMPARE_EQ_NBOOL_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
8630 if (&PyFloat_Type == Py_TYPE(operand2)) {
8631 return COMPARE_EQ_CBOOL_FLOAT_FLOAT(operand1, operand2) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8634#if PYTHON_VERSION < 0x300
8635 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
8636 return NUITKA_BOOL_EXCEPTION;
8639 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
8640 return NUITKA_BOOL_EXCEPTION;
8644 PyTypeObject *type2 = Py_TYPE(operand2);
8646#if PYTHON_VERSION < 0x300
8648 if (&PyFloat_Type == type2 && !0) {
8650 richcmpfunc frich = PyFloat_Type.tp_richcompare;
8652 if (frich != NULL) {
8653 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
8655 if (result != Py_NotImplemented) {
8656 Py_LeaveRecursiveCall();
8658 if (unlikely(result == NULL)) {
8659 return NUITKA_BOOL_EXCEPTION;
8663 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8669 Py_DECREF_IMMORTAL(result);
8673 cmpfunc fcmp = NULL;
8676 int c = (*fcmp)(operand1, operand2);
8677 c = adjust_tp_compare(c);
8679 Py_LeaveRecursiveCall();
8682 return NUITKA_BOOL_EXCEPTION;
8705 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
8709 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8718 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8719 f = TP_RICHCOMPARE(type2);
8722 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8724 if (result != Py_NotImplemented) {
8725 Py_LeaveRecursiveCall();
8727 if (unlikely(result == NULL)) {
8728 return NUITKA_BOOL_EXCEPTION;
8732 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8738 Py_DECREF_IMMORTAL(result);
8742 f = PyFloat_Type.tp_richcompare;
8744 PyObject *result = (*f)(operand1, operand2, Py_EQ);
8746 if (result != Py_NotImplemented) {
8747 Py_LeaveRecursiveCall();
8749 if (unlikely(result == NULL)) {
8750 return NUITKA_BOOL_EXCEPTION;
8754 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8760 Py_DECREF_IMMORTAL(result);
8763 f = TP_RICHCOMPARE(type2);
8765 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8767 if (result != Py_NotImplemented) {
8768 Py_LeaveRecursiveCall();
8770 if (unlikely(result == NULL)) {
8771 return NUITKA_BOOL_EXCEPTION;
8775 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8781 Py_DECREF_IMMORTAL(result);
8787 cmpfunc fcmp = NULL;
8788 c = (*fcmp)(operand1, operand2);
8789 }
else if (PyInstance_Check(operand2)) {
8790 cmpfunc fcmp = type2->tp_compare;
8791 c = (*fcmp)(operand1, operand2);
8793 c = try_3way_compare(operand1, operand2);
8797 if (&PyFloat_Type == type2) {
8798 Py_uintptr_t aa = (Py_uintptr_t)operand1;
8799 Py_uintptr_t bb = (Py_uintptr_t)operand2;
8801 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8802 }
else if (operand1 == Py_None) {
8805 }
else if (operand2 == Py_None) {
8808 }
else if (PyNumber_Check(operand1)) {
8811 if (PyNumber_Check(operand2)) {
8813 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8814 Py_uintptr_t bb = (Py_uintptr_t)type2;
8816 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8820 }
else if (PyNumber_Check(operand2)) {
8824 int s = strcmp(
"float", type2->tp_name);
8832 Py_uintptr_t aa = (Py_uintptr_t)&PyFloat_Type;
8833 Py_uintptr_t bb = (Py_uintptr_t)type2;
8835 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
8840 Py_LeaveRecursiveCall();
8842 if (unlikely(c <= -2)) {
8843 return NUITKA_BOOL_EXCEPTION;
8868 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8872 bool checked_reverse_op =
false;
8875 if (&PyFloat_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
8876 f = TP_RICHCOMPARE(type2);
8879 checked_reverse_op =
true;
8881 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8883 if (result != Py_NotImplemented) {
8884 Py_LeaveRecursiveCall();
8886 if (unlikely(result == NULL)) {
8887 return NUITKA_BOOL_EXCEPTION;
8891 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8897 Py_DECREF_IMMORTAL(result);
8901 f = PyFloat_Type.tp_richcompare;
8904 PyObject *result = (*f)(operand1, operand2, Py_EQ);
8906 if (result != Py_NotImplemented) {
8907 Py_LeaveRecursiveCall();
8909 if (unlikely(result == NULL)) {
8910 return NUITKA_BOOL_EXCEPTION;
8914 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8920 Py_DECREF_IMMORTAL(result);
8923 if (checked_reverse_op ==
false) {
8924 f = TP_RICHCOMPARE(type2);
8927 PyObject *result = (*f)(operand2, operand1, Py_EQ);
8929 if (result != Py_NotImplemented) {
8930 Py_LeaveRecursiveCall();
8932 if (unlikely(result == NULL)) {
8933 return NUITKA_BOOL_EXCEPTION;
8937 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8943 Py_DECREF_IMMORTAL(result);
8947 Py_LeaveRecursiveCall();
8953 bool r = operand1 == operand2;
8954 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8959 bool r = operand1 != operand2;
8960 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
8965#if PYTHON_VERSION < 0x360
8966 PyErr_Format(PyExc_TypeError,
"unorderable types: float() == %s()", type2->tp_name);
8968 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'float' and '%s'", type2->tp_name);
8970 return NUITKA_BOOL_EXCEPTION;
8975static PyObject *COMPARE_EQ_OBJECT_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
8976 CHECK_OBJECT(operand1);
8977 assert(PyTuple_CheckExact(operand1));
8978 CHECK_OBJECT(operand2);
8979 assert(PyTuple_CheckExact(operand2));
8981 PyTupleObject *a = (PyTupleObject *)operand1;
8982 PyTupleObject *b = (PyTupleObject *)operand2;
8984 Py_ssize_t len_a = Py_SIZE(a);
8985 Py_ssize_t len_b = Py_SIZE(b);
8987 if (len_a != len_b) {
8991 PyObject *result = BOOL_FROM(r);
8992 Py_INCREF_IMMORTAL(result);
8996 nuitka_bool res = NUITKA_BOOL_TRUE;
8999 for (i = 0; i < len_a && i < len_b; i++) {
9000 PyObject *aa = a->ob_item[i];
9001 PyObject *bb = b->ob_item[i];
9007 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
9009 if (res == NUITKA_BOOL_EXCEPTION) {
9013 if (res == NUITKA_BOOL_FALSE) {
9018 bool r = res == NUITKA_BOOL_TRUE;
9021 PyObject *result = BOOL_FROM(r);
9022 Py_INCREF_IMMORTAL(result);
9026PyObject *RICH_COMPARE_EQ_OBJECT_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
9028 if (Py_TYPE(operand1) == &PyTuple_Type) {
9029 return COMPARE_EQ_OBJECT_TUPLE_TUPLE(operand1, operand2);
9032#if PYTHON_VERSION < 0x300
9033 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9037 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9042 PyTypeObject *type1 = Py_TYPE(operand1);
9044#if PYTHON_VERSION < 0x300
9046 if (type1 == &PyTuple_Type && !0) {
9048 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9050 if (frich != NULL) {
9051 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
9053 if (result != Py_NotImplemented) {
9054 Py_LeaveRecursiveCall();
9059 Py_DECREF_IMMORTAL(result);
9063 cmpfunc fcmp = NULL;
9066 int c = (*fcmp)(operand1, operand2);
9067 c = adjust_tp_compare(c);
9069 Py_LeaveRecursiveCall();
9095 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9099 PyObject *result = BOOL_FROM(r);
9100 Py_INCREF_IMMORTAL(result);
9108 if (type1 != &PyTuple_Type && 0) {
9109 f = PyTuple_Type.tp_richcompare;
9112 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9114 if (result != Py_NotImplemented) {
9115 Py_LeaveRecursiveCall();
9120 Py_DECREF_IMMORTAL(result);
9124 f = TP_RICHCOMPARE(type1);
9126 PyObject *result = (*f)(operand1, operand2, Py_EQ);
9128 if (result != Py_NotImplemented) {
9129 Py_LeaveRecursiveCall();
9134 Py_DECREF_IMMORTAL(result);
9137 f = PyTuple_Type.tp_richcompare;
9139 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9141 if (result != Py_NotImplemented) {
9142 Py_LeaveRecursiveCall();
9147 Py_DECREF_IMMORTAL(result);
9152 if (PyInstance_Check(operand1)) {
9153 cmpfunc fcmp = type1->tp_compare;
9154 c = (*fcmp)(operand1, operand2);
9156 cmpfunc fcmp = NULL;
9157 c = (*fcmp)(operand1, operand2);
9159 c = try_3way_compare(operand1, operand2);
9163 if (type1 == &PyTuple_Type) {
9164 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9165 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9167 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9168 }
else if (operand1 == Py_None) {
9171 }
else if (operand2 == Py_None) {
9174 }
else if (PyNumber_Check(operand1)) {
9177 if (PyNumber_Check(operand2)) {
9179 Py_uintptr_t aa = (Py_uintptr_t)type1;
9180 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9182 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9186 }
else if (PyNumber_Check(operand2)) {
9190 int s = strcmp(type1->tp_name,
"tuple");
9198 Py_uintptr_t aa = (Py_uintptr_t)type1;
9199 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9201 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9206 Py_LeaveRecursiveCall();
9208 if (unlikely(c <= -2)) {
9234 PyObject *result = BOOL_FROM(r);
9235 Py_INCREF_IMMORTAL(result);
9238 bool checked_reverse_op =
false;
9241 if (type1 != &PyTuple_Type && Nuitka_Type_IsSubtype(&PyTuple_Type, type1)) {
9242 f = PyTuple_Type.tp_richcompare;
9245 checked_reverse_op =
true;
9247 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9249 if (result != Py_NotImplemented) {
9250 Py_LeaveRecursiveCall();
9255 Py_DECREF_IMMORTAL(result);
9259 f = TP_RICHCOMPARE(type1);
9262 PyObject *result = (*f)(operand1, operand2, Py_EQ);
9264 if (result != Py_NotImplemented) {
9265 Py_LeaveRecursiveCall();
9270 Py_DECREF_IMMORTAL(result);
9273 if (checked_reverse_op ==
false) {
9274 f = PyTuple_Type.tp_richcompare;
9277 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9279 if (result != Py_NotImplemented) {
9280 Py_LeaveRecursiveCall();
9285 Py_DECREF_IMMORTAL(result);
9289 Py_LeaveRecursiveCall();
9295 bool r = operand1 == operand2;
9296 PyObject *result = BOOL_FROM(r);
9297 Py_INCREF_IMMORTAL(result);
9301 bool r = operand1 != operand2;
9302 PyObject *result = BOOL_FROM(r);
9303 Py_INCREF_IMMORTAL(result);
9307#if PYTHON_VERSION < 0x360
9308 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == tuple()", type1->tp_name);
9310 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'tuple'", type1->tp_name);
9318PyObject *RICH_COMPARE_EQ_OBJECT_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
9320 if (&PyTuple_Type == Py_TYPE(operand2)) {
9321 return COMPARE_EQ_OBJECT_TUPLE_TUPLE(operand1, operand2);
9324#if PYTHON_VERSION < 0x300
9325 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9329 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9334 PyTypeObject *type2 = Py_TYPE(operand2);
9336#if PYTHON_VERSION < 0x300
9338 if (&PyTuple_Type == type2 && !0) {
9340 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9342 if (frich != NULL) {
9343 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
9345 if (result != Py_NotImplemented) {
9346 Py_LeaveRecursiveCall();
9351 Py_DECREF_IMMORTAL(result);
9355 cmpfunc fcmp = NULL;
9358 int c = (*fcmp)(operand1, operand2);
9359 c = adjust_tp_compare(c);
9361 Py_LeaveRecursiveCall();
9387 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9391 PyObject *result = BOOL_FROM(r);
9392 Py_INCREF_IMMORTAL(result);
9400 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9401 f = TP_RICHCOMPARE(type2);
9404 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9406 if (result != Py_NotImplemented) {
9407 Py_LeaveRecursiveCall();
9412 Py_DECREF_IMMORTAL(result);
9416 f = PyTuple_Type.tp_richcompare;
9418 PyObject *result = (*f)(operand1, operand2, Py_EQ);
9420 if (result != Py_NotImplemented) {
9421 Py_LeaveRecursiveCall();
9426 Py_DECREF_IMMORTAL(result);
9429 f = TP_RICHCOMPARE(type2);
9431 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9433 if (result != Py_NotImplemented) {
9434 Py_LeaveRecursiveCall();
9439 Py_DECREF_IMMORTAL(result);
9445 cmpfunc fcmp = NULL;
9446 c = (*fcmp)(operand1, operand2);
9447 }
else if (PyInstance_Check(operand2)) {
9448 cmpfunc fcmp = type2->tp_compare;
9449 c = (*fcmp)(operand1, operand2);
9451 c = try_3way_compare(operand1, operand2);
9455 if (&PyTuple_Type == type2) {
9456 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9457 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9459 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9460 }
else if (operand1 == Py_None) {
9463 }
else if (operand2 == Py_None) {
9466 }
else if (PyNumber_Check(operand1)) {
9469 if (PyNumber_Check(operand2)) {
9471 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
9472 Py_uintptr_t bb = (Py_uintptr_t)type2;
9474 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9478 }
else if (PyNumber_Check(operand2)) {
9482 int s = strcmp(
"tuple", type2->tp_name);
9490 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
9491 Py_uintptr_t bb = (Py_uintptr_t)type2;
9493 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9498 Py_LeaveRecursiveCall();
9500 if (unlikely(c <= -2)) {
9526 PyObject *result = BOOL_FROM(r);
9527 Py_INCREF_IMMORTAL(result);
9530 bool checked_reverse_op =
false;
9533 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
9534 f = TP_RICHCOMPARE(type2);
9537 checked_reverse_op =
true;
9539 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9541 if (result != Py_NotImplemented) {
9542 Py_LeaveRecursiveCall();
9547 Py_DECREF_IMMORTAL(result);
9551 f = PyTuple_Type.tp_richcompare;
9554 PyObject *result = (*f)(operand1, operand2, Py_EQ);
9556 if (result != Py_NotImplemented) {
9557 Py_LeaveRecursiveCall();
9562 Py_DECREF_IMMORTAL(result);
9565 if (checked_reverse_op ==
false) {
9566 f = TP_RICHCOMPARE(type2);
9569 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9571 if (result != Py_NotImplemented) {
9572 Py_LeaveRecursiveCall();
9577 Py_DECREF_IMMORTAL(result);
9581 Py_LeaveRecursiveCall();
9587 bool r = operand1 == operand2;
9588 PyObject *result = BOOL_FROM(r);
9589 Py_INCREF_IMMORTAL(result);
9593 bool r = operand1 != operand2;
9594 PyObject *result = BOOL_FROM(r);
9595 Py_INCREF_IMMORTAL(result);
9599#if PYTHON_VERSION < 0x360
9600 PyErr_Format(PyExc_TypeError,
"unorderable types: tuple() == %s()", type2->tp_name);
9602 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'tuple' and '%s'", type2->tp_name);
9610PyObject *RICH_COMPARE_EQ_OBJECT_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
9612 return COMPARE_EQ_OBJECT_TUPLE_TUPLE(operand1, operand2);
9615static nuitka_bool COMPARE_EQ_NBOOL_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
9616 CHECK_OBJECT(operand1);
9617 assert(PyTuple_CheckExact(operand1));
9618 CHECK_OBJECT(operand2);
9619 assert(PyTuple_CheckExact(operand2));
9621 PyTupleObject *a = (PyTupleObject *)operand1;
9622 PyTupleObject *b = (PyTupleObject *)operand2;
9624 Py_ssize_t len_a = Py_SIZE(a);
9625 Py_ssize_t len_b = Py_SIZE(b);
9627 if (len_a != len_b) {
9631 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9636 nuitka_bool res = NUITKA_BOOL_TRUE;
9639 for (i = 0; i < len_a && i < len_b; i++) {
9640 PyObject *aa = a->ob_item[i];
9641 PyObject *bb = b->ob_item[i];
9647 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
9649 if (res == NUITKA_BOOL_EXCEPTION) {
9650 return NUITKA_BOOL_EXCEPTION;
9653 if (res == NUITKA_BOOL_FALSE) {
9658 bool r = res == NUITKA_BOOL_TRUE;
9661 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9666nuitka_bool RICH_COMPARE_EQ_NBOOL_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
9668 if (Py_TYPE(operand1) == &PyTuple_Type) {
9669 return COMPARE_EQ_NBOOL_TUPLE_TUPLE(operand1, operand2);
9672#if PYTHON_VERSION < 0x300
9673 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
9674 return NUITKA_BOOL_EXCEPTION;
9677 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
9678 return NUITKA_BOOL_EXCEPTION;
9682 PyTypeObject *type1 = Py_TYPE(operand1);
9684#if PYTHON_VERSION < 0x300
9686 if (type1 == &PyTuple_Type && !0) {
9688 richcmpfunc frich = PyTuple_Type.tp_richcompare;
9690 if (frich != NULL) {
9691 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
9693 if (result != Py_NotImplemented) {
9694 Py_LeaveRecursiveCall();
9696 if (unlikely(result == NULL)) {
9697 return NUITKA_BOOL_EXCEPTION;
9701 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9707 Py_DECREF_IMMORTAL(result);
9711 cmpfunc fcmp = NULL;
9714 int c = (*fcmp)(operand1, operand2);
9715 c = adjust_tp_compare(c);
9717 Py_LeaveRecursiveCall();
9720 return NUITKA_BOOL_EXCEPTION;
9743 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
9747 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9756 if (type1 != &PyTuple_Type && 0) {
9757 f = PyTuple_Type.tp_richcompare;
9760 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9762 if (result != Py_NotImplemented) {
9763 Py_LeaveRecursiveCall();
9765 if (unlikely(result == NULL)) {
9766 return NUITKA_BOOL_EXCEPTION;
9770 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9776 Py_DECREF_IMMORTAL(result);
9780 f = TP_RICHCOMPARE(type1);
9782 PyObject *result = (*f)(operand1, operand2, Py_EQ);
9784 if (result != Py_NotImplemented) {
9785 Py_LeaveRecursiveCall();
9787 if (unlikely(result == NULL)) {
9788 return NUITKA_BOOL_EXCEPTION;
9792 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9798 Py_DECREF_IMMORTAL(result);
9801 f = PyTuple_Type.tp_richcompare;
9803 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9805 if (result != Py_NotImplemented) {
9806 Py_LeaveRecursiveCall();
9808 if (unlikely(result == NULL)) {
9809 return NUITKA_BOOL_EXCEPTION;
9813 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9819 Py_DECREF_IMMORTAL(result);
9824 if (PyInstance_Check(operand1)) {
9825 cmpfunc fcmp = type1->tp_compare;
9826 c = (*fcmp)(operand1, operand2);
9828 cmpfunc fcmp = NULL;
9829 c = (*fcmp)(operand1, operand2);
9831 c = try_3way_compare(operand1, operand2);
9835 if (type1 == &PyTuple_Type) {
9836 Py_uintptr_t aa = (Py_uintptr_t)operand1;
9837 Py_uintptr_t bb = (Py_uintptr_t)operand2;
9839 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9840 }
else if (operand1 == Py_None) {
9843 }
else if (operand2 == Py_None) {
9846 }
else if (PyNumber_Check(operand1)) {
9849 if (PyNumber_Check(operand2)) {
9851 Py_uintptr_t aa = (Py_uintptr_t)type1;
9852 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9854 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9858 }
else if (PyNumber_Check(operand2)) {
9862 int s = strcmp(type1->tp_name,
"tuple");
9870 Py_uintptr_t aa = (Py_uintptr_t)type1;
9871 Py_uintptr_t bb = (Py_uintptr_t)&PyTuple_Type;
9873 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
9878 Py_LeaveRecursiveCall();
9880 if (unlikely(c <= -2)) {
9881 return NUITKA_BOOL_EXCEPTION;
9906 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9910 bool checked_reverse_op =
false;
9913 if (type1 != &PyTuple_Type && Nuitka_Type_IsSubtype(&PyTuple_Type, type1)) {
9914 f = PyTuple_Type.tp_richcompare;
9917 checked_reverse_op =
true;
9919 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9921 if (result != Py_NotImplemented) {
9922 Py_LeaveRecursiveCall();
9924 if (unlikely(result == NULL)) {
9925 return NUITKA_BOOL_EXCEPTION;
9929 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9935 Py_DECREF_IMMORTAL(result);
9939 f = TP_RICHCOMPARE(type1);
9942 PyObject *result = (*f)(operand1, operand2, Py_EQ);
9944 if (result != Py_NotImplemented) {
9945 Py_LeaveRecursiveCall();
9947 if (unlikely(result == NULL)) {
9948 return NUITKA_BOOL_EXCEPTION;
9952 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9958 Py_DECREF_IMMORTAL(result);
9961 if (checked_reverse_op ==
false) {
9962 f = PyTuple_Type.tp_richcompare;
9965 PyObject *result = (*f)(operand2, operand1, Py_EQ);
9967 if (result != Py_NotImplemented) {
9968 Py_LeaveRecursiveCall();
9970 if (unlikely(result == NULL)) {
9971 return NUITKA_BOOL_EXCEPTION;
9975 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9981 Py_DECREF_IMMORTAL(result);
9985 Py_LeaveRecursiveCall();
9991 bool r = operand1 == operand2;
9992 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
9997 bool r = operand1 != operand2;
9998 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10003#if PYTHON_VERSION < 0x360
10004 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == tuple()", type1->tp_name);
10006 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'tuple'", type1->tp_name);
10008 return NUITKA_BOOL_EXCEPTION;
10014nuitka_bool RICH_COMPARE_EQ_NBOOL_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
10016 if (&PyTuple_Type == Py_TYPE(operand2)) {
10017 return COMPARE_EQ_NBOOL_TUPLE_TUPLE(operand1, operand2);
10020#if PYTHON_VERSION < 0x300
10021 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10022 return NUITKA_BOOL_EXCEPTION;
10025 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10026 return NUITKA_BOOL_EXCEPTION;
10030 PyTypeObject *type2 = Py_TYPE(operand2);
10032#if PYTHON_VERSION < 0x300
10034 if (&PyTuple_Type == type2 && !0) {
10036 richcmpfunc frich = PyTuple_Type.tp_richcompare;
10038 if (frich != NULL) {
10039 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
10041 if (result != Py_NotImplemented) {
10042 Py_LeaveRecursiveCall();
10044 if (unlikely(result == NULL)) {
10045 return NUITKA_BOOL_EXCEPTION;
10049 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10055 Py_DECREF_IMMORTAL(result);
10059 cmpfunc fcmp = NULL;
10061 if (fcmp != NULL) {
10062 int c = (*fcmp)(operand1, operand2);
10063 c = adjust_tp_compare(c);
10065 Py_LeaveRecursiveCall();
10068 return NUITKA_BOOL_EXCEPTION;
10091 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10095 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10104 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
10105 f = TP_RICHCOMPARE(type2);
10108 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10110 if (result != Py_NotImplemented) {
10111 Py_LeaveRecursiveCall();
10113 if (unlikely(result == NULL)) {
10114 return NUITKA_BOOL_EXCEPTION;
10118 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10124 Py_DECREF_IMMORTAL(result);
10128 f = PyTuple_Type.tp_richcompare;
10130 PyObject *result = (*f)(operand1, operand2, Py_EQ);
10132 if (result != Py_NotImplemented) {
10133 Py_LeaveRecursiveCall();
10135 if (unlikely(result == NULL)) {
10136 return NUITKA_BOOL_EXCEPTION;
10140 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10146 Py_DECREF_IMMORTAL(result);
10149 f = TP_RICHCOMPARE(type2);
10151 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10153 if (result != Py_NotImplemented) {
10154 Py_LeaveRecursiveCall();
10156 if (unlikely(result == NULL)) {
10157 return NUITKA_BOOL_EXCEPTION;
10161 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10167 Py_DECREF_IMMORTAL(result);
10173 cmpfunc fcmp = NULL;
10174 c = (*fcmp)(operand1, operand2);
10175 }
else if (PyInstance_Check(operand2)) {
10176 cmpfunc fcmp = type2->tp_compare;
10177 c = (*fcmp)(operand1, operand2);
10179 c = try_3way_compare(operand1, operand2);
10183 if (&PyTuple_Type == type2) {
10184 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10185 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10187 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10188 }
else if (operand1 == Py_None) {
10191 }
else if (operand2 == Py_None) {
10194 }
else if (PyNumber_Check(operand1)) {
10197 if (PyNumber_Check(operand2)) {
10199 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
10200 Py_uintptr_t bb = (Py_uintptr_t)type2;
10202 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10206 }
else if (PyNumber_Check(operand2)) {
10210 int s = strcmp(
"tuple", type2->tp_name);
10214 }
else if (s > 0) {
10218 Py_uintptr_t aa = (Py_uintptr_t)&PyTuple_Type;
10219 Py_uintptr_t bb = (Py_uintptr_t)type2;
10221 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10226 Py_LeaveRecursiveCall();
10228 if (unlikely(c <= -2)) {
10229 return NUITKA_BOOL_EXCEPTION;
10254 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10258 bool checked_reverse_op =
false;
10261 if (&PyTuple_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyTuple_Type)) {
10262 f = TP_RICHCOMPARE(type2);
10265 checked_reverse_op =
true;
10267 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10269 if (result != Py_NotImplemented) {
10270 Py_LeaveRecursiveCall();
10272 if (unlikely(result == NULL)) {
10273 return NUITKA_BOOL_EXCEPTION;
10277 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10283 Py_DECREF_IMMORTAL(result);
10287 f = PyTuple_Type.tp_richcompare;
10290 PyObject *result = (*f)(operand1, operand2, Py_EQ);
10292 if (result != Py_NotImplemented) {
10293 Py_LeaveRecursiveCall();
10295 if (unlikely(result == NULL)) {
10296 return NUITKA_BOOL_EXCEPTION;
10300 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10306 Py_DECREF_IMMORTAL(result);
10309 if (checked_reverse_op ==
false) {
10310 f = TP_RICHCOMPARE(type2);
10313 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10315 if (result != Py_NotImplemented) {
10316 Py_LeaveRecursiveCall();
10318 if (unlikely(result == NULL)) {
10319 return NUITKA_BOOL_EXCEPTION;
10323 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10329 Py_DECREF_IMMORTAL(result);
10333 Py_LeaveRecursiveCall();
10339 bool r = operand1 == operand2;
10340 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10345 bool r = operand1 != operand2;
10346 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
10351#if PYTHON_VERSION < 0x360
10352 PyErr_Format(PyExc_TypeError,
"unorderable types: tuple() == %s()", type2->tp_name);
10354 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'tuple' and '%s'", type2->tp_name);
10356 return NUITKA_BOOL_EXCEPTION;
10362nuitka_bool RICH_COMPARE_EQ_NBOOL_TUPLE_TUPLE(PyObject *operand1, PyObject *operand2) {
10364 return COMPARE_EQ_NBOOL_TUPLE_TUPLE(operand1, operand2);
10367static PyObject *COMPARE_EQ_OBJECT_LIST_LIST(PyObject *operand1, PyObject *operand2) {
10368 CHECK_OBJECT(operand1);
10369 assert(PyList_CheckExact(operand1));
10370 CHECK_OBJECT(operand2);
10371 assert(PyList_CheckExact(operand2));
10373 PyListObject *a = (PyListObject *)operand1;
10374 PyListObject *b = (PyListObject *)operand2;
10376 if (Py_SIZE(a) != Py_SIZE(b)) {
10380 PyObject *result = BOOL_FROM(r);
10381 Py_INCREF_IMMORTAL(result);
10385 nuitka_bool res = NUITKA_BOOL_TRUE;
10388 for (i = 0; i < Py_SIZE(a) && i < Py_SIZE(b); i++) {
10389 PyObject *aa = a->ob_item[i];
10390 PyObject *bb = b->ob_item[i];
10398 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
10402 if (res == NUITKA_BOOL_EXCEPTION) {
10406 if (res == NUITKA_BOOL_FALSE) {
10412 if (i >= Py_SIZE(a) || i >= Py_SIZE(b)) {
10413 r = Py_SIZE(a) == Py_SIZE(b);
10415 r = res == NUITKA_BOOL_TRUE;
10419 PyObject *result = BOOL_FROM(r);
10420 Py_INCREF_IMMORTAL(result);
10424PyObject *RICH_COMPARE_EQ_OBJECT_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
10426 if (Py_TYPE(operand1) == &PyList_Type) {
10427 return COMPARE_EQ_OBJECT_LIST_LIST(operand1, operand2);
10430#if PYTHON_VERSION < 0x300
10431 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10435 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10440 PyTypeObject *type1 = Py_TYPE(operand1);
10442#if PYTHON_VERSION < 0x300
10444 if (type1 == &PyList_Type && !0) {
10446 richcmpfunc frich = PyList_Type.tp_richcompare;
10448 if (frich != NULL) {
10449 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
10451 if (result != Py_NotImplemented) {
10452 Py_LeaveRecursiveCall();
10457 Py_DECREF_IMMORTAL(result);
10461 cmpfunc fcmp = NULL;
10463 if (fcmp != NULL) {
10464 int c = (*fcmp)(operand1, operand2);
10465 c = adjust_tp_compare(c);
10467 Py_LeaveRecursiveCall();
10493 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10497 PyObject *result = BOOL_FROM(r);
10498 Py_INCREF_IMMORTAL(result);
10506 if (type1 != &PyList_Type && 0) {
10507 f = PyList_Type.tp_richcompare;
10510 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10512 if (result != Py_NotImplemented) {
10513 Py_LeaveRecursiveCall();
10518 Py_DECREF_IMMORTAL(result);
10522 f = TP_RICHCOMPARE(type1);
10524 PyObject *result = (*f)(operand1, operand2, Py_EQ);
10526 if (result != Py_NotImplemented) {
10527 Py_LeaveRecursiveCall();
10532 Py_DECREF_IMMORTAL(result);
10535 f = PyList_Type.tp_richcompare;
10537 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10539 if (result != Py_NotImplemented) {
10540 Py_LeaveRecursiveCall();
10545 Py_DECREF_IMMORTAL(result);
10550 if (PyInstance_Check(operand1)) {
10551 cmpfunc fcmp = type1->tp_compare;
10552 c = (*fcmp)(operand1, operand2);
10554 cmpfunc fcmp = NULL;
10555 c = (*fcmp)(operand1, operand2);
10557 c = try_3way_compare(operand1, operand2);
10561 if (type1 == &PyList_Type) {
10562 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10563 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10565 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10566 }
else if (operand1 == Py_None) {
10569 }
else if (operand2 == Py_None) {
10572 }
else if (PyNumber_Check(operand1)) {
10575 if (PyNumber_Check(operand2)) {
10577 Py_uintptr_t aa = (Py_uintptr_t)type1;
10578 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
10580 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10584 }
else if (PyNumber_Check(operand2)) {
10588 int s = strcmp(type1->tp_name,
"list");
10592 }
else if (s > 0) {
10596 Py_uintptr_t aa = (Py_uintptr_t)type1;
10597 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
10599 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10604 Py_LeaveRecursiveCall();
10606 if (unlikely(c <= -2)) {
10632 PyObject *result = BOOL_FROM(r);
10633 Py_INCREF_IMMORTAL(result);
10636 bool checked_reverse_op =
false;
10639 if (type1 != &PyList_Type && Nuitka_Type_IsSubtype(&PyList_Type, type1)) {
10640 f = PyList_Type.tp_richcompare;
10643 checked_reverse_op =
true;
10645 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10647 if (result != Py_NotImplemented) {
10648 Py_LeaveRecursiveCall();
10653 Py_DECREF_IMMORTAL(result);
10657 f = TP_RICHCOMPARE(type1);
10660 PyObject *result = (*f)(operand1, operand2, Py_EQ);
10662 if (result != Py_NotImplemented) {
10663 Py_LeaveRecursiveCall();
10668 Py_DECREF_IMMORTAL(result);
10671 if (checked_reverse_op ==
false) {
10672 f = PyList_Type.tp_richcompare;
10675 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10677 if (result != Py_NotImplemented) {
10678 Py_LeaveRecursiveCall();
10683 Py_DECREF_IMMORTAL(result);
10687 Py_LeaveRecursiveCall();
10693 bool r = operand1 == operand2;
10694 PyObject *result = BOOL_FROM(r);
10695 Py_INCREF_IMMORTAL(result);
10699 bool r = operand1 != operand2;
10700 PyObject *result = BOOL_FROM(r);
10701 Py_INCREF_IMMORTAL(result);
10705#if PYTHON_VERSION < 0x360
10706 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == list()", type1->tp_name);
10708 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'list'", type1->tp_name);
10716PyObject *RICH_COMPARE_EQ_OBJECT_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
10718 if (&PyList_Type == Py_TYPE(operand2)) {
10719 return COMPARE_EQ_OBJECT_LIST_LIST(operand1, operand2);
10722#if PYTHON_VERSION < 0x300
10723 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
10727 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
10732 PyTypeObject *type2 = Py_TYPE(operand2);
10734#if PYTHON_VERSION < 0x300
10736 if (&PyList_Type == type2 && !0) {
10738 richcmpfunc frich = PyList_Type.tp_richcompare;
10740 if (frich != NULL) {
10741 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
10743 if (result != Py_NotImplemented) {
10744 Py_LeaveRecursiveCall();
10749 Py_DECREF_IMMORTAL(result);
10753 cmpfunc fcmp = NULL;
10755 if (fcmp != NULL) {
10756 int c = (*fcmp)(operand1, operand2);
10757 c = adjust_tp_compare(c);
10759 Py_LeaveRecursiveCall();
10785 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
10789 PyObject *result = BOOL_FROM(r);
10790 Py_INCREF_IMMORTAL(result);
10798 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
10799 f = TP_RICHCOMPARE(type2);
10802 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10804 if (result != Py_NotImplemented) {
10805 Py_LeaveRecursiveCall();
10810 Py_DECREF_IMMORTAL(result);
10814 f = PyList_Type.tp_richcompare;
10816 PyObject *result = (*f)(operand1, operand2, Py_EQ);
10818 if (result != Py_NotImplemented) {
10819 Py_LeaveRecursiveCall();
10824 Py_DECREF_IMMORTAL(result);
10827 f = TP_RICHCOMPARE(type2);
10829 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10831 if (result != Py_NotImplemented) {
10832 Py_LeaveRecursiveCall();
10837 Py_DECREF_IMMORTAL(result);
10843 cmpfunc fcmp = NULL;
10844 c = (*fcmp)(operand1, operand2);
10845 }
else if (PyInstance_Check(operand2)) {
10846 cmpfunc fcmp = type2->tp_compare;
10847 c = (*fcmp)(operand1, operand2);
10849 c = try_3way_compare(operand1, operand2);
10853 if (&PyList_Type == type2) {
10854 Py_uintptr_t aa = (Py_uintptr_t)operand1;
10855 Py_uintptr_t bb = (Py_uintptr_t)operand2;
10857 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10858 }
else if (operand1 == Py_None) {
10861 }
else if (operand2 == Py_None) {
10864 }
else if (PyNumber_Check(operand1)) {
10867 if (PyNumber_Check(operand2)) {
10869 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
10870 Py_uintptr_t bb = (Py_uintptr_t)type2;
10872 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10876 }
else if (PyNumber_Check(operand2)) {
10880 int s = strcmp(
"list", type2->tp_name);
10884 }
else if (s > 0) {
10888 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
10889 Py_uintptr_t bb = (Py_uintptr_t)type2;
10891 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
10896 Py_LeaveRecursiveCall();
10898 if (unlikely(c <= -2)) {
10924 PyObject *result = BOOL_FROM(r);
10925 Py_INCREF_IMMORTAL(result);
10928 bool checked_reverse_op =
false;
10931 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
10932 f = TP_RICHCOMPARE(type2);
10935 checked_reverse_op =
true;
10937 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10939 if (result != Py_NotImplemented) {
10940 Py_LeaveRecursiveCall();
10945 Py_DECREF_IMMORTAL(result);
10949 f = PyList_Type.tp_richcompare;
10952 PyObject *result = (*f)(operand1, operand2, Py_EQ);
10954 if (result != Py_NotImplemented) {
10955 Py_LeaveRecursiveCall();
10960 Py_DECREF_IMMORTAL(result);
10963 if (checked_reverse_op ==
false) {
10964 f = TP_RICHCOMPARE(type2);
10967 PyObject *result = (*f)(operand2, operand1, Py_EQ);
10969 if (result != Py_NotImplemented) {
10970 Py_LeaveRecursiveCall();
10975 Py_DECREF_IMMORTAL(result);
10979 Py_LeaveRecursiveCall();
10985 bool r = operand1 == operand2;
10986 PyObject *result = BOOL_FROM(r);
10987 Py_INCREF_IMMORTAL(result);
10991 bool r = operand1 != operand2;
10992 PyObject *result = BOOL_FROM(r);
10993 Py_INCREF_IMMORTAL(result);
10997#if PYTHON_VERSION < 0x360
10998 PyErr_Format(PyExc_TypeError,
"unorderable types: list() == %s()", type2->tp_name);
11000 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'list' and '%s'", type2->tp_name);
11008PyObject *RICH_COMPARE_EQ_OBJECT_LIST_LIST(PyObject *operand1, PyObject *operand2) {
11010 return COMPARE_EQ_OBJECT_LIST_LIST(operand1, operand2);
11013static nuitka_bool COMPARE_EQ_NBOOL_LIST_LIST(PyObject *operand1, PyObject *operand2) {
11014 CHECK_OBJECT(operand1);
11015 assert(PyList_CheckExact(operand1));
11016 CHECK_OBJECT(operand2);
11017 assert(PyList_CheckExact(operand2));
11019 PyListObject *a = (PyListObject *)operand1;
11020 PyListObject *b = (PyListObject *)operand2;
11022 if (Py_SIZE(a) != Py_SIZE(b)) {
11026 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11031 nuitka_bool res = NUITKA_BOOL_TRUE;
11034 for (i = 0; i < Py_SIZE(a) && i < Py_SIZE(b); i++) {
11035 PyObject *aa = a->ob_item[i];
11036 PyObject *bb = b->ob_item[i];
11044 res = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(aa, bb);
11048 if (res == NUITKA_BOOL_EXCEPTION) {
11049 return NUITKA_BOOL_EXCEPTION;
11052 if (res == NUITKA_BOOL_FALSE) {
11058 if (i >= Py_SIZE(a) || i >= Py_SIZE(b)) {
11059 r = Py_SIZE(a) == Py_SIZE(b);
11061 r = res == NUITKA_BOOL_TRUE;
11065 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11070nuitka_bool RICH_COMPARE_EQ_NBOOL_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
11072 if (Py_TYPE(operand1) == &PyList_Type) {
11073 return COMPARE_EQ_NBOOL_LIST_LIST(operand1, operand2);
11076#if PYTHON_VERSION < 0x300
11077 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
11078 return NUITKA_BOOL_EXCEPTION;
11081 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
11082 return NUITKA_BOOL_EXCEPTION;
11086 PyTypeObject *type1 = Py_TYPE(operand1);
11088#if PYTHON_VERSION < 0x300
11090 if (type1 == &PyList_Type && !0) {
11092 richcmpfunc frich = PyList_Type.tp_richcompare;
11094 if (frich != NULL) {
11095 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
11097 if (result != Py_NotImplemented) {
11098 Py_LeaveRecursiveCall();
11100 if (unlikely(result == NULL)) {
11101 return NUITKA_BOOL_EXCEPTION;
11105 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11111 Py_DECREF_IMMORTAL(result);
11115 cmpfunc fcmp = NULL;
11117 if (fcmp != NULL) {
11118 int c = (*fcmp)(operand1, operand2);
11119 c = adjust_tp_compare(c);
11121 Py_LeaveRecursiveCall();
11124 return NUITKA_BOOL_EXCEPTION;
11147 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
11151 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11160 if (type1 != &PyList_Type && 0) {
11161 f = PyList_Type.tp_richcompare;
11164 PyObject *result = (*f)(operand2, operand1, Py_EQ);
11166 if (result != Py_NotImplemented) {
11167 Py_LeaveRecursiveCall();
11169 if (unlikely(result == NULL)) {
11170 return NUITKA_BOOL_EXCEPTION;
11174 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11180 Py_DECREF_IMMORTAL(result);
11184 f = TP_RICHCOMPARE(type1);
11186 PyObject *result = (*f)(operand1, operand2, Py_EQ);
11188 if (result != Py_NotImplemented) {
11189 Py_LeaveRecursiveCall();
11191 if (unlikely(result == NULL)) {
11192 return NUITKA_BOOL_EXCEPTION;
11196 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11202 Py_DECREF_IMMORTAL(result);
11205 f = PyList_Type.tp_richcompare;
11207 PyObject *result = (*f)(operand2, operand1, Py_EQ);
11209 if (result != Py_NotImplemented) {
11210 Py_LeaveRecursiveCall();
11212 if (unlikely(result == NULL)) {
11213 return NUITKA_BOOL_EXCEPTION;
11217 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11223 Py_DECREF_IMMORTAL(result);
11228 if (PyInstance_Check(operand1)) {
11229 cmpfunc fcmp = type1->tp_compare;
11230 c = (*fcmp)(operand1, operand2);
11232 cmpfunc fcmp = NULL;
11233 c = (*fcmp)(operand1, operand2);
11235 c = try_3way_compare(operand1, operand2);
11239 if (type1 == &PyList_Type) {
11240 Py_uintptr_t aa = (Py_uintptr_t)operand1;
11241 Py_uintptr_t bb = (Py_uintptr_t)operand2;
11243 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11244 }
else if (operand1 == Py_None) {
11247 }
else if (operand2 == Py_None) {
11250 }
else if (PyNumber_Check(operand1)) {
11253 if (PyNumber_Check(operand2)) {
11255 Py_uintptr_t aa = (Py_uintptr_t)type1;
11256 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
11258 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11262 }
else if (PyNumber_Check(operand2)) {
11266 int s = strcmp(type1->tp_name,
"list");
11270 }
else if (s > 0) {
11274 Py_uintptr_t aa = (Py_uintptr_t)type1;
11275 Py_uintptr_t bb = (Py_uintptr_t)&PyList_Type;
11277 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11282 Py_LeaveRecursiveCall();
11284 if (unlikely(c <= -2)) {
11285 return NUITKA_BOOL_EXCEPTION;
11310 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11314 bool checked_reverse_op =
false;
11317 if (type1 != &PyList_Type && Nuitka_Type_IsSubtype(&PyList_Type, type1)) {
11318 f = PyList_Type.tp_richcompare;
11321 checked_reverse_op =
true;
11323 PyObject *result = (*f)(operand2, operand1, Py_EQ);
11325 if (result != Py_NotImplemented) {
11326 Py_LeaveRecursiveCall();
11328 if (unlikely(result == NULL)) {
11329 return NUITKA_BOOL_EXCEPTION;
11333 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11339 Py_DECREF_IMMORTAL(result);
11343 f = TP_RICHCOMPARE(type1);
11346 PyObject *result = (*f)(operand1, operand2, Py_EQ);
11348 if (result != Py_NotImplemented) {
11349 Py_LeaveRecursiveCall();
11351 if (unlikely(result == NULL)) {
11352 return NUITKA_BOOL_EXCEPTION;
11356 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11362 Py_DECREF_IMMORTAL(result);
11365 if (checked_reverse_op ==
false) {
11366 f = PyList_Type.tp_richcompare;
11369 PyObject *result = (*f)(operand2, operand1, Py_EQ);
11371 if (result != Py_NotImplemented) {
11372 Py_LeaveRecursiveCall();
11374 if (unlikely(result == NULL)) {
11375 return NUITKA_BOOL_EXCEPTION;
11379 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11385 Py_DECREF_IMMORTAL(result);
11389 Py_LeaveRecursiveCall();
11395 bool r = operand1 == operand2;
11396 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11401 bool r = operand1 != operand2;
11402 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11407#if PYTHON_VERSION < 0x360
11408 PyErr_Format(PyExc_TypeError,
"unorderable types: %s() == list()", type1->tp_name);
11410 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of '%s' and 'list'", type1->tp_name);
11412 return NUITKA_BOOL_EXCEPTION;
11418nuitka_bool RICH_COMPARE_EQ_NBOOL_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
11420 if (&PyList_Type == Py_TYPE(operand2)) {
11421 return COMPARE_EQ_NBOOL_LIST_LIST(operand1, operand2);
11424#if PYTHON_VERSION < 0x300
11425 if (unlikely(Py_EnterRecursiveCall((
char *)
" in cmp"))) {
11426 return NUITKA_BOOL_EXCEPTION;
11429 if (unlikely(Py_EnterRecursiveCall((
char *)
" in comparison"))) {
11430 return NUITKA_BOOL_EXCEPTION;
11434 PyTypeObject *type2 = Py_TYPE(operand2);
11436#if PYTHON_VERSION < 0x300
11438 if (&PyList_Type == type2 && !0) {
11440 richcmpfunc frich = PyList_Type.tp_richcompare;
11442 if (frich != NULL) {
11443 PyObject *result = (*frich)(operand1, operand2, Py_EQ);
11445 if (result != Py_NotImplemented) {
11446 Py_LeaveRecursiveCall();
11448 if (unlikely(result == NULL)) {
11449 return NUITKA_BOOL_EXCEPTION;
11453 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11459 Py_DECREF_IMMORTAL(result);
11463 cmpfunc fcmp = NULL;
11465 if (fcmp != NULL) {
11466 int c = (*fcmp)(operand1, operand2);
11467 c = adjust_tp_compare(c);
11469 Py_LeaveRecursiveCall();
11472 return NUITKA_BOOL_EXCEPTION;
11495 NUITKA_CANNOT_GET_HERE(
"wrong op_code");
11499 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11508 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
11509 f = TP_RICHCOMPARE(type2);
11512 PyObject *result = (*f)(operand2, operand1, Py_EQ);
11514 if (result != Py_NotImplemented) {
11515 Py_LeaveRecursiveCall();
11517 if (unlikely(result == NULL)) {
11518 return NUITKA_BOOL_EXCEPTION;
11522 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11528 Py_DECREF_IMMORTAL(result);
11532 f = PyList_Type.tp_richcompare;
11534 PyObject *result = (*f)(operand1, operand2, Py_EQ);
11536 if (result != Py_NotImplemented) {
11537 Py_LeaveRecursiveCall();
11539 if (unlikely(result == NULL)) {
11540 return NUITKA_BOOL_EXCEPTION;
11544 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11550 Py_DECREF_IMMORTAL(result);
11553 f = TP_RICHCOMPARE(type2);
11555 PyObject *result = (*f)(operand2, operand1, Py_EQ);
11557 if (result != Py_NotImplemented) {
11558 Py_LeaveRecursiveCall();
11560 if (unlikely(result == NULL)) {
11561 return NUITKA_BOOL_EXCEPTION;
11565 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11571 Py_DECREF_IMMORTAL(result);
11577 cmpfunc fcmp = NULL;
11578 c = (*fcmp)(operand1, operand2);
11579 }
else if (PyInstance_Check(operand2)) {
11580 cmpfunc fcmp = type2->tp_compare;
11581 c = (*fcmp)(operand1, operand2);
11583 c = try_3way_compare(operand1, operand2);
11587 if (&PyList_Type == type2) {
11588 Py_uintptr_t aa = (Py_uintptr_t)operand1;
11589 Py_uintptr_t bb = (Py_uintptr_t)operand2;
11591 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11592 }
else if (operand1 == Py_None) {
11595 }
else if (operand2 == Py_None) {
11598 }
else if (PyNumber_Check(operand1)) {
11601 if (PyNumber_Check(operand2)) {
11603 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
11604 Py_uintptr_t bb = (Py_uintptr_t)type2;
11606 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11610 }
else if (PyNumber_Check(operand2)) {
11614 int s = strcmp(
"list", type2->tp_name);
11618 }
else if (s > 0) {
11622 Py_uintptr_t aa = (Py_uintptr_t)&PyList_Type;
11623 Py_uintptr_t bb = (Py_uintptr_t)type2;
11625 c = (aa < bb) ? -1 : (aa > bb) ? 1 : 0;
11630 Py_LeaveRecursiveCall();
11632 if (unlikely(c <= -2)) {
11633 return NUITKA_BOOL_EXCEPTION;
11658 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11662 bool checked_reverse_op =
false;
11665 if (&PyList_Type != type2 && Nuitka_Type_IsSubtype(type2, &PyList_Type)) {
11666 f = TP_RICHCOMPARE(type2);
11669 checked_reverse_op =
true;
11671 PyObject *result = (*f)(operand2, operand1, Py_EQ);
11673 if (result != Py_NotImplemented) {
11674 Py_LeaveRecursiveCall();
11676 if (unlikely(result == NULL)) {
11677 return NUITKA_BOOL_EXCEPTION;
11681 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11687 Py_DECREF_IMMORTAL(result);
11691 f = PyList_Type.tp_richcompare;
11694 PyObject *result = (*f)(operand1, operand2, Py_EQ);
11696 if (result != Py_NotImplemented) {
11697 Py_LeaveRecursiveCall();
11699 if (unlikely(result == NULL)) {
11700 return NUITKA_BOOL_EXCEPTION;
11704 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11710 Py_DECREF_IMMORTAL(result);
11713 if (checked_reverse_op ==
false) {
11714 f = TP_RICHCOMPARE(type2);
11717 PyObject *result = (*f)(operand2, operand1, Py_EQ);
11719 if (result != Py_NotImplemented) {
11720 Py_LeaveRecursiveCall();
11722 if (unlikely(result == NULL)) {
11723 return NUITKA_BOOL_EXCEPTION;
11727 nuitka_bool r = CHECK_IF_TRUE(result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11733 Py_DECREF_IMMORTAL(result);
11737 Py_LeaveRecursiveCall();
11743 bool r = operand1 == operand2;
11744 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11749 bool r = operand1 != operand2;
11750 nuitka_bool result = r ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
11755#if PYTHON_VERSION < 0x360
11756 PyErr_Format(PyExc_TypeError,
"unorderable types: list() == %s()", type2->tp_name);
11758 PyErr_Format(PyExc_TypeError,
"'==' not supported between instances of 'list' and '%s'", type2->tp_name);
11760 return NUITKA_BOOL_EXCEPTION;
11766nuitka_bool RICH_COMPARE_EQ_NBOOL_LIST_LIST(PyObject *operand1, PyObject *operand2) {
11768 return COMPARE_EQ_NBOOL_LIST_LIST(operand1, operand2);
11771static PyObject *COMPARE_EQ_OBJECT_LONG_CLONG(PyObject *operand1,
long operand2) {
11772 CHECK_OBJECT(operand1);
11773 assert(PyLong_CheckExact(operand1));
11775 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11777 bool operand2_is_negative;
11778 unsigned long operand2_abs_ival;
11780 if (operand2 < 0) {
11781 operand2_abs_ival = (
unsigned long)(-1 - operand2) + 1;
11782 operand2_is_negative =
true;
11784 operand2_abs_ival = (
unsigned long)operand2;
11785 operand2_is_negative =
false;
11788 Py_ssize_t operand2_digit_count = 0;
11789 digit operand2_digits[5] = {0};
11791 unsigned long t = operand2_abs_ival;
11794 operand2_digit_count += 1;
11795 assert(operand2_digit_count <= (Py_ssize_t)(
sizeof(operand2_digit_count) /
sizeof(digit)));
11797 operand2_digits[operand2_digit_count] = (digit)(t & PyLong_MASK);
11798 t >>= PyLong_SHIFT;
11802 NUITKA_MAY_BE_UNUSED Py_ssize_t operand2_size =
11803 operand2_is_negative ==
false ? operand2_digit_count : -operand2_digit_count;
11807 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) != operand2_size) {
11810 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11814 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != operand2_digits[i]) {
11822 PyObject *result = BOOL_FROM(r);
11823 Py_INCREF_IMMORTAL(result);
11826#if PYTHON_VERSION < 0x300
11828PyObject *RICH_COMPARE_EQ_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
11830 return COMPARE_EQ_OBJECT_LONG_CLONG(operand1, PyInt_AS_LONG(operand1));
11834static bool COMPARE_EQ_CBOOL_LONG_CLONG(PyObject *operand1,
long operand2) {
11835 CHECK_OBJECT(operand1);
11836 assert(PyLong_CheckExact(operand1));
11838 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11840 bool operand2_is_negative;
11841 unsigned long operand2_abs_ival;
11843 if (operand2 < 0) {
11844 operand2_abs_ival = (
unsigned long)(-1 - operand2) + 1;
11845 operand2_is_negative =
true;
11847 operand2_abs_ival = (
unsigned long)operand2;
11848 operand2_is_negative =
false;
11851 Py_ssize_t operand2_digit_count = 0;
11852 digit operand2_digits[5] = {0};
11854 unsigned long t = operand2_abs_ival;
11857 operand2_digit_count += 1;
11858 assert(operand2_digit_count <= (Py_ssize_t)(
sizeof(operand2_digit_count) /
sizeof(digit)));
11860 operand2_digits[operand2_digit_count] = (digit)(t & PyLong_MASK);
11861 t >>= PyLong_SHIFT;
11865 NUITKA_MAY_BE_UNUSED Py_ssize_t operand2_size =
11866 operand2_is_negative ==
false ? operand2_digit_count : -operand2_digit_count;
11870 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) != operand2_size) {
11873 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11877 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != operand2_digits[i]) {
11889#if PYTHON_VERSION < 0x300
11891bool RICH_COMPARE_EQ_CBOOL_LONG_INT(PyObject *operand1, PyObject *operand2) {
11893 return COMPARE_EQ_CBOOL_LONG_CLONG(operand1, PyInt_AS_LONG(operand1));
11897#if PYTHON_VERSION < 0x300
11898static PyObject *COMPARE_EQ_OBJECT_INT_CLONG(PyObject *operand1,
long operand2) {
11899 CHECK_OBJECT(operand1);
11900 assert(PyInt_CheckExact(operand1));
11902 const long a = PyInt_AS_LONG(operand1);
11903 const long b = operand2;
11908 PyObject *result = BOOL_FROM(r);
11909 Py_INCREF_IMMORTAL(result);
11913#if PYTHON_VERSION < 0x300
11915PyObject *RICH_COMPARE_EQ_OBJECT_INT_CLONG(PyObject *operand1,
long operand2) {
11917 return COMPARE_EQ_OBJECT_INT_CLONG(operand1, operand2);
11921#if PYTHON_VERSION < 0x300
11922static bool COMPARE_EQ_CBOOL_INT_CLONG(PyObject *operand1,
long operand2) {
11923 CHECK_OBJECT(operand1);
11924 assert(PyInt_CheckExact(operand1));
11926 const long a = PyInt_AS_LONG(operand1);
11927 const long b = operand2;
11937#if PYTHON_VERSION < 0x300
11939bool RICH_COMPARE_EQ_CBOOL_INT_CLONG(PyObject *operand1,
long operand2) {
11941 return COMPARE_EQ_CBOOL_INT_CLONG(operand1, operand2);
11945static PyObject *COMPARE_EQ_OBJECT_LONG_DIGIT(PyObject *operand1,
long operand2) {
11946 CHECK_OBJECT(operand1);
11947 assert(PyLong_CheckExact(operand1));
11948 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
11950 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11954 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
11955 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1))) {
11958 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11962 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != (digit)Py_ABS(operand2)) {
11970 PyObject *result = BOOL_FROM(r);
11971 Py_INCREF_IMMORTAL(result);
11976PyObject *RICH_COMPARE_EQ_OBJECT_LONG_DIGIT(PyObject *operand1,
long operand2) {
11978 return COMPARE_EQ_OBJECT_LONG_DIGIT(operand1, operand2);
11981static bool COMPARE_EQ_CBOOL_LONG_DIGIT(PyObject *operand1,
long operand2) {
11982 CHECK_OBJECT(operand1);
11983 assert(PyLong_CheckExact(operand1));
11984 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
11986 PyLongObject *operand1_long_object = (PyLongObject *)operand1;
11990 if (Nuitka_LongGetSignedDigitSize(operand1_long_object) !=
11991 (Py_ssize_t)((operand2 == 0) ? 0 : ((operand2 < 0) ? -1 : 1))) {
11994 Py_ssize_t i = Nuitka_LongGetDigitSize(operand1_long_object);
11998 if (Nuitka_LongGetDigitPointer(operand1_long_object)[i] != (digit)Py_ABS(operand2)) {
12012bool RICH_COMPARE_EQ_CBOOL_LONG_DIGIT(PyObject *operand1,
long operand2) {
12014 return COMPARE_EQ_CBOOL_LONG_DIGIT(operand1, operand2);
12017static PyObject *COMPARE_EQ_OBJECT_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
12018 CHECK_OBJECT(operand1);
12019 assert(PyFloat_CheckExact(operand1));
12021 const double a = PyFloat_AS_DOUBLE(operand1);
12022 const double b = operand2;
12027 PyObject *result = BOOL_FROM(r);
12028 Py_INCREF_IMMORTAL(result);
12032PyObject *RICH_COMPARE_EQ_OBJECT_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
12034 return COMPARE_EQ_OBJECT_FLOAT_CFLOAT(operand1, operand2);
12037static bool COMPARE_EQ_CBOOL_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
12038 CHECK_OBJECT(operand1);
12039 assert(PyFloat_CheckExact(operand1));
12041 const double a = PyFloat_AS_DOUBLE(operand1);
12042 const double b = operand2;
12052bool RICH_COMPARE_EQ_CBOOL_FLOAT_CFLOAT(PyObject *operand1,
double operand2) {
12054 return COMPARE_EQ_CBOOL_FLOAT_CFLOAT(operand1, operand2);