7#include "nuitka/prelude.h"
10#include "HelpersOperationBinaryPowUtils.c"
14static PyObject *_BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
15 CHECK_OBJECT(operand1);
16 assert(PyFloat_CheckExact(operand1));
17 CHECK_OBJECT(operand2);
18 assert(PyFloat_CheckExact(operand2));
24#pragma warning(disable : 4101)
27 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
28 NUITKA_MAY_BE_UNUSED
long clong_result;
29 NUITKA_MAY_BE_UNUSED
double cfloat_result;
34 CHECK_OBJECT(operand1);
35 assert(PyFloat_CheckExact(operand1));
36 CHECK_OBJECT(operand2);
37 assert(PyFloat_CheckExact(operand2));
39 double a = PyFloat_AS_DOUBLE(operand1);
40 const double b = PyFloat_AS_DOUBLE(operand2);
43 goto exit_result_ok_const_float_1_0;
47 goto exit_result_ok_left;
52 goto exit_result_ok_const_float_1_0;
54 goto exit_result_ok_right;
58 if (Py_IS_INFINITY(b)) {
61 goto exit_result_ok_const_float_1_0;
62 }
else if ((b > 0.0) == (a > 1.0)) {
63 long r = (long)fabs(b);
66 goto exit_result_ok_cfloat;
68 goto exit_result_ok_const_float_0_0;
72 if (Py_IS_INFINITY(a)) {
73 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
77 r = b_is_odd ? a : fabs(a);
79 r = b_is_odd ? copysign(0.0, a) : 0.0;
83 goto exit_result_ok_cfloat;
87 if (unlikely(b < 0.0)) {
88 PyThreadState *tstate = PyThreadState_GET();
90 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
91 "0.0 cannot be raised to a negative power");
92 goto exit_result_exception;
95 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
96 double r = b_is_odd ? a : 0.0;
99 goto exit_result_ok_cfloat;
103 bool negate_result =
false;
106 if (unlikely(b != floor(b))) {
107 PyThreadState *tstate = PyThreadState_GET();
109 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
110 "negative number cannot be raised to a fractional power");
111 goto exit_result_exception;
115 negate_result = DOUBLE_IS_ODD_INTEGER(b);
120 goto exit_result_ok_const_float_minus_1_0;
122 goto exit_result_ok_const_float_1_0;
126 double r = pow(a, b);
128 if (unlikely(errno != 0)) {
129 PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : PyExc_ValueError);
130 goto exit_result_exception;
133 r = negate_result ? -r : r;
136 goto exit_result_ok_cfloat;
140exit_result_ok_cfloat:
141 result = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
154exit_result_ok_const_float_0_0:
155 Py_INCREF(const_float_0_0);
156 result = const_float_0_0;
159exit_result_ok_const_float_1_0:
160 Py_INCREF(const_float_1_0);
161 result = const_float_1_0;
164exit_result_ok_const_float_minus_1_0:
165 Py_INCREF(const_float_minus_1_0);
166 result = const_float_minus_1_0;
172exit_result_exception:
176PyObject *BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
177 return _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1, operand2);
181static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_POW_OBJECT_OBJECT_FLOAT(PyObject *operand1,
182 PyObject *operand2) {
183 PyTypeObject *type1 = Py_TYPE(operand1);
187#pragma warning(disable : 4101)
189 NUITKA_MAY_BE_UNUSED
bool cbool_result;
190 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
196 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_power : NULL;
197 ternaryfunc slot2 = NULL;
199 if (!(type1 == &PyFloat_Type)) {
202 slot2 = PyFloat_Type.tp_as_number->nb_power;
204 if (slot1 == slot2) {
210 PyObject *x = slot1(operand1, operand2, Py_None);
212 if (x != Py_NotImplemented) {
214 goto exit_binary_result_object;
217 Py_DECREF_IMMORTAL(x);
221 PyObject *x = slot2(operand1, operand2, Py_None);
223 if (x != Py_NotImplemented) {
225 goto exit_binary_result_object;
228 Py_DECREF_IMMORTAL(x);
231#if PYTHON_VERSION < 0x300
232 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
234 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
237 PyObject *coerced1 = operand1;
238 PyObject *coerced2 = operand2;
240 int err = c1(&coerced1, &coerced2);
242 if (unlikely(err < 0)) {
243 goto exit_binary_exception;
247 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
249 if (likely(mv == NULL)) {
250 ternaryfunc slot = mv->nb_power;
252 if (likely(slot != NULL)) {
253 PyObject *x = slot(coerced1, coerced2, Py_None);
259 goto exit_binary_result_object;
268 coercion c2 = PyFloat_Type.tp_as_number->nb_coerce;
271 PyObject *coerced1 = operand1;
272 PyObject *coerced2 = operand2;
274 int err = c2(&coerced2, &coerced1);
276 if (unlikely(err < 0)) {
277 goto exit_binary_exception;
281 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
283 if (likely(mv == NULL)) {
284 ternaryfunc slot = mv->nb_power;
286 if (likely(slot != NULL)) {
287 PyObject *x = slot(coerced1, coerced2, Py_None);
293 goto exit_binary_result_object;
305 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): '%s' and 'float'", type1->tp_name);
306 goto exit_binary_exception;
308exit_binary_result_object:
311exit_binary_exception:
314static PyObject *_BINARY_OPERATION_POW_OBJECT_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
315 CHECK_OBJECT(operand1);
316 CHECK_OBJECT(operand2);
317 assert(PyFloat_CheckExact(operand2));
319 PyTypeObject *type1 = Py_TYPE(operand1);
321 if (type1 == &PyFloat_Type) {
328#pragma warning(disable : 4101)
331 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
332 NUITKA_MAY_BE_UNUSED
long clong_result;
333 NUITKA_MAY_BE_UNUSED
double cfloat_result;
338 CHECK_OBJECT(operand1);
339 assert(PyFloat_CheckExact(operand1));
340 CHECK_OBJECT(operand2);
341 assert(PyFloat_CheckExact(operand2));
343 double a = PyFloat_AS_DOUBLE(operand1);
344 const double b = PyFloat_AS_DOUBLE(operand2);
347 goto exit_result_ok_const_float_1_0;
351 goto exit_result_ok_left;
356 goto exit_result_ok_const_float_1_0;
358 goto exit_result_ok_right;
362 if (Py_IS_INFINITY(b)) {
365 goto exit_result_ok_const_float_1_0;
366 }
else if ((b > 0.0) == (a > 1.0)) {
367 long r = (long)fabs(b);
370 goto exit_result_ok_cfloat;
372 goto exit_result_ok_const_float_0_0;
376 if (Py_IS_INFINITY(a)) {
377 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
381 r = b_is_odd ? a : fabs(a);
383 r = b_is_odd ? copysign(0.0, a) : 0.0;
387 goto exit_result_ok_cfloat;
391 if (unlikely(b < 0.0)) {
392 PyThreadState *tstate = PyThreadState_GET();
394 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
395 "0.0 cannot be raised to a negative power");
396 goto exit_result_exception;
399 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
400 double r = b_is_odd ? a : 0.0;
403 goto exit_result_ok_cfloat;
407 bool negate_result =
false;
410 if (unlikely(b != floor(b))) {
411 PyThreadState *tstate = PyThreadState_GET();
413 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
414 "negative number cannot be raised to a fractional power");
415 goto exit_result_exception;
419 negate_result = DOUBLE_IS_ODD_INTEGER(b);
424 goto exit_result_ok_const_float_minus_1_0;
426 goto exit_result_ok_const_float_1_0;
430 double r = pow(a, b);
432 if (unlikely(errno != 0)) {
433 PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : PyExc_ValueError);
434 goto exit_result_exception;
437 r = negate_result ? -r : r;
440 goto exit_result_ok_cfloat;
444 exit_result_ok_cfloat:
445 result = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
453 exit_result_ok_right:
458 exit_result_ok_const_float_0_0:
459 Py_INCREF(const_float_0_0);
460 result = const_float_0_0;
463 exit_result_ok_const_float_1_0:
464 Py_INCREF(const_float_1_0);
465 result = const_float_1_0;
468 exit_result_ok_const_float_minus_1_0:
469 Py_INCREF(const_float_minus_1_0);
470 result = const_float_minus_1_0;
476 exit_result_exception:
480 return __BINARY_OPERATION_POW_OBJECT_OBJECT_FLOAT(operand1, operand2);
483PyObject *BINARY_OPERATION_POW_OBJECT_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
484 return _BINARY_OPERATION_POW_OBJECT_OBJECT_FLOAT(operand1, operand2);
488static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_POW_OBJECT_FLOAT_OBJECT(PyObject *operand1,
489 PyObject *operand2) {
490 PyTypeObject *type2 = Py_TYPE(operand2);
494#pragma warning(disable : 4101)
496 NUITKA_MAY_BE_UNUSED
bool cbool_result;
497 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
502 ternaryfunc slot1 = PyFloat_Type.tp_as_number->nb_power;
503 ternaryfunc slot2 = NULL;
505 if (!(&PyFloat_Type == type2)) {
508 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_power : NULL;
510 if (slot1 == slot2) {
517 if (Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
518 PyObject *x = slot2(operand1, operand2, Py_None);
520 if (x != Py_NotImplemented) {
522 goto exit_binary_result_object;
525 Py_DECREF_IMMORTAL(x);
530 PyObject *x = slot1(operand1, operand2, Py_None);
532 if (x != Py_NotImplemented) {
534 goto exit_binary_result_object;
537 Py_DECREF_IMMORTAL(x);
541 PyObject *x = slot2(operand1, operand2, Py_None);
543 if (x != Py_NotImplemented) {
545 goto exit_binary_result_object;
548 Py_DECREF_IMMORTAL(x);
551#if PYTHON_VERSION < 0x300
552 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
553 coercion c1 = PyFloat_Type.tp_as_number->nb_coerce;
556 PyObject *coerced1 = operand1;
557 PyObject *coerced2 = operand2;
559 int err = c1(&coerced1, &coerced2);
561 if (unlikely(err < 0)) {
562 goto exit_binary_exception;
566 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
568 if (likely(mv == NULL)) {
569 ternaryfunc slot = mv->nb_power;
571 if (likely(slot != NULL)) {
572 PyObject *x = slot(coerced1, coerced2, Py_None);
578 goto exit_binary_result_object;
588 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
591 PyObject *coerced1 = operand1;
592 PyObject *coerced2 = operand2;
594 int err = c2(&coerced2, &coerced1);
596 if (unlikely(err < 0)) {
597 goto exit_binary_exception;
601 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
603 if (likely(mv == NULL)) {
604 ternaryfunc slot = mv->nb_power;
606 if (likely(slot != NULL)) {
607 PyObject *x = slot(coerced1, coerced2, Py_None);
613 goto exit_binary_result_object;
625 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'float' and '%s'", type2->tp_name);
626 goto exit_binary_exception;
628exit_binary_result_object:
631exit_binary_exception:
634static PyObject *_BINARY_OPERATION_POW_OBJECT_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
635 CHECK_OBJECT(operand1);
636 assert(PyFloat_CheckExact(operand1));
637 CHECK_OBJECT(operand2);
639 PyTypeObject *type2 = Py_TYPE(operand2);
641 if (&PyFloat_Type == type2) {
648#pragma warning(disable : 4101)
651 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
652 NUITKA_MAY_BE_UNUSED
long clong_result;
653 NUITKA_MAY_BE_UNUSED
double cfloat_result;
658 CHECK_OBJECT(operand1);
659 assert(PyFloat_CheckExact(operand1));
660 CHECK_OBJECT(operand2);
661 assert(PyFloat_CheckExact(operand2));
663 double a = PyFloat_AS_DOUBLE(operand1);
664 const double b = PyFloat_AS_DOUBLE(operand2);
667 goto exit_result_ok_const_float_1_0;
671 goto exit_result_ok_left;
676 goto exit_result_ok_const_float_1_0;
678 goto exit_result_ok_right;
682 if (Py_IS_INFINITY(b)) {
685 goto exit_result_ok_const_float_1_0;
686 }
else if ((b > 0.0) == (a > 1.0)) {
687 long r = (long)fabs(b);
690 goto exit_result_ok_cfloat;
692 goto exit_result_ok_const_float_0_0;
696 if (Py_IS_INFINITY(a)) {
697 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
701 r = b_is_odd ? a : fabs(a);
703 r = b_is_odd ? copysign(0.0, a) : 0.0;
707 goto exit_result_ok_cfloat;
711 if (unlikely(b < 0.0)) {
712 PyThreadState *tstate = PyThreadState_GET();
714 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
715 "0.0 cannot be raised to a negative power");
716 goto exit_result_exception;
719 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
720 double r = b_is_odd ? a : 0.0;
723 goto exit_result_ok_cfloat;
727 bool negate_result =
false;
730 if (unlikely(b != floor(b))) {
731 PyThreadState *tstate = PyThreadState_GET();
733 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
734 "negative number cannot be raised to a fractional power");
735 goto exit_result_exception;
739 negate_result = DOUBLE_IS_ODD_INTEGER(b);
744 goto exit_result_ok_const_float_minus_1_0;
746 goto exit_result_ok_const_float_1_0;
750 double r = pow(a, b);
752 if (unlikely(errno != 0)) {
753 PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : PyExc_ValueError);
754 goto exit_result_exception;
757 r = negate_result ? -r : r;
760 goto exit_result_ok_cfloat;
764 exit_result_ok_cfloat:
765 result = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
773 exit_result_ok_right:
778 exit_result_ok_const_float_0_0:
779 Py_INCREF(const_float_0_0);
780 result = const_float_0_0;
783 exit_result_ok_const_float_1_0:
784 Py_INCREF(const_float_1_0);
785 result = const_float_1_0;
788 exit_result_ok_const_float_minus_1_0:
789 Py_INCREF(const_float_minus_1_0);
790 result = const_float_minus_1_0;
796 exit_result_exception:
800 return __BINARY_OPERATION_POW_OBJECT_FLOAT_OBJECT(operand1, operand2);
803PyObject *BINARY_OPERATION_POW_OBJECT_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
804 return _BINARY_OPERATION_POW_OBJECT_FLOAT_OBJECT(operand1, operand2);
808static PyObject *_BINARY_OPERATION_POW_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
809 CHECK_OBJECT(operand1);
810 assert(PyLong_CheckExact(operand1));
811 CHECK_OBJECT(operand2);
812 assert(PyLong_CheckExact(operand2));
819#pragma warning(disable : 4101)
821 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
822 NUITKA_MAY_BE_UNUSED
long clong_result;
827 PyObject *x = PyLong_Type.tp_as_number->nb_power(operand1, operand2, Py_None);
828 assert(x != Py_NotImplemented);
831 goto exit_result_object;
834 if (unlikely(obj_result == NULL)) {
835 goto exit_result_exception;
843exit_result_exception:
847PyObject *BINARY_OPERATION_POW_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
848 return _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1, operand2);
852static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_POW_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
853 PyTypeObject *type1 = Py_TYPE(operand1);
857#pragma warning(disable : 4101)
859 NUITKA_MAY_BE_UNUSED
bool cbool_result;
860 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
866 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_power : NULL;
867 ternaryfunc slot2 = NULL;
869 if (!(type1 == &PyLong_Type)) {
872 slot2 = PyLong_Type.tp_as_number->nb_power;
874 if (slot1 == slot2) {
880 PyObject *x = slot1(operand1, operand2, Py_None);
882 if (x != Py_NotImplemented) {
884 goto exit_binary_result_object;
887 Py_DECREF_IMMORTAL(x);
891 PyObject *x = slot2(operand1, operand2, Py_None);
893 if (x != Py_NotImplemented) {
895 goto exit_binary_result_object;
898 Py_DECREF_IMMORTAL(x);
901#if PYTHON_VERSION < 0x300
902 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
904 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
907 PyObject *coerced1 = operand1;
908 PyObject *coerced2 = operand2;
910 int err = c1(&coerced1, &coerced2);
912 if (unlikely(err < 0)) {
913 goto exit_binary_exception;
917 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
919 if (likely(mv == NULL)) {
920 ternaryfunc slot = mv->nb_power;
922 if (likely(slot != NULL)) {
923 PyObject *x = slot(coerced1, coerced2, Py_None);
929 goto exit_binary_result_object;
938 coercion c2 = PyLong_Type.tp_as_number->nb_coerce;
941 PyObject *coerced1 = operand1;
942 PyObject *coerced2 = operand2;
944 int err = c2(&coerced2, &coerced1);
946 if (unlikely(err < 0)) {
947 goto exit_binary_exception;
951 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
953 if (likely(mv == NULL)) {
954 ternaryfunc slot = mv->nb_power;
956 if (likely(slot != NULL)) {
957 PyObject *x = slot(coerced1, coerced2, Py_None);
963 goto exit_binary_result_object;
975#if PYTHON_VERSION < 0x300
976 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): '%s' and 'long'", type1->tp_name);
978 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): '%s' and 'int'", type1->tp_name);
980 goto exit_binary_exception;
982exit_binary_result_object:
985exit_binary_exception:
988static PyObject *_BINARY_OPERATION_POW_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
989 CHECK_OBJECT(operand1);
990 CHECK_OBJECT(operand2);
991 assert(PyLong_CheckExact(operand2));
993 PyTypeObject *type1 = Py_TYPE(operand1);
995 if (type1 == &PyLong_Type) {
1001#if defined(_MSC_VER)
1002#pragma warning(push)
1003#pragma warning(disable : 4101)
1005 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1006 NUITKA_MAY_BE_UNUSED
long clong_result;
1007#if defined(_MSC_VER)
1011 PyObject *x = PyLong_Type.tp_as_number->nb_power(operand1, operand2, Py_None);
1012 assert(x != Py_NotImplemented);
1015 goto exit_result_object;
1018 if (unlikely(obj_result == NULL)) {
1019 goto exit_result_exception;
1021 result = obj_result;
1022 goto exit_result_ok;
1027 exit_result_exception:
1031 return __BINARY_OPERATION_POW_OBJECT_OBJECT_LONG(operand1, operand2);
1034PyObject *BINARY_OPERATION_POW_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
1035 return _BINARY_OPERATION_POW_OBJECT_OBJECT_LONG(operand1, operand2);
1039static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_POW_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
1040 PyTypeObject *type2 = Py_TYPE(operand2);
1042#if defined(_MSC_VER)
1043#pragma warning(push)
1044#pragma warning(disable : 4101)
1046 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1047 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1048#if defined(_MSC_VER)
1052 ternaryfunc slot1 = PyLong_Type.tp_as_number->nb_power;
1053 ternaryfunc slot2 = NULL;
1055 if (!(&PyLong_Type == type2)) {
1058 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_power : NULL;
1060 if (slot1 == slot2) {
1065 if (slot1 != NULL) {
1066 if (slot2 != NULL) {
1067 if (Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
1068 PyObject *x = slot2(operand1, operand2, Py_None);
1070 if (x != Py_NotImplemented) {
1072 goto exit_binary_result_object;
1075 Py_DECREF_IMMORTAL(x);
1080 PyObject *x = slot1(operand1, operand2, Py_None);
1082 if (x != Py_NotImplemented) {
1084 goto exit_binary_result_object;
1087 Py_DECREF_IMMORTAL(x);
1090 if (slot2 != NULL) {
1091 PyObject *x = slot2(operand1, operand2, Py_None);
1093 if (x != Py_NotImplemented) {
1095 goto exit_binary_result_object;
1098 Py_DECREF_IMMORTAL(x);
1101#if PYTHON_VERSION < 0x300
1102 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1103 coercion c1 = PyLong_Type.tp_as_number->nb_coerce;
1106 PyObject *coerced1 = operand1;
1107 PyObject *coerced2 = operand2;
1109 int err = c1(&coerced1, &coerced2);
1111 if (unlikely(err < 0)) {
1112 goto exit_binary_exception;
1116 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1118 if (likely(mv == NULL)) {
1119 ternaryfunc slot = mv->nb_power;
1121 if (likely(slot != NULL)) {
1122 PyObject *x = slot(coerced1, coerced2, Py_None);
1124 Py_DECREF(coerced1);
1125 Py_DECREF(coerced2);
1128 goto exit_binary_result_object;
1133 Py_DECREF(coerced1);
1134 Py_DECREF(coerced2);
1138 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1141 PyObject *coerced1 = operand1;
1142 PyObject *coerced2 = operand2;
1144 int err = c2(&coerced2, &coerced1);
1146 if (unlikely(err < 0)) {
1147 goto exit_binary_exception;
1151 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1153 if (likely(mv == NULL)) {
1154 ternaryfunc slot = mv->nb_power;
1156 if (likely(slot != NULL)) {
1157 PyObject *x = slot(coerced1, coerced2, Py_None);
1159 Py_DECREF(coerced1);
1160 Py_DECREF(coerced2);
1163 goto exit_binary_result_object;
1168 Py_DECREF(coerced1);
1169 Py_DECREF(coerced2);
1175#if PYTHON_VERSION < 0x300
1176 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'long' and '%s'", type2->tp_name);
1178 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'int' and '%s'", type2->tp_name);
1180 goto exit_binary_exception;
1182exit_binary_result_object:
1185exit_binary_exception:
1188static PyObject *_BINARY_OPERATION_POW_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
1189 CHECK_OBJECT(operand1);
1190 assert(PyLong_CheckExact(operand1));
1191 CHECK_OBJECT(operand2);
1193 PyTypeObject *type2 = Py_TYPE(operand2);
1195 if (&PyLong_Type == type2) {
1201#if defined(_MSC_VER)
1202#pragma warning(push)
1203#pragma warning(disable : 4101)
1205 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1206 NUITKA_MAY_BE_UNUSED
long clong_result;
1207#if defined(_MSC_VER)
1211 PyObject *x = PyLong_Type.tp_as_number->nb_power(operand1, operand2, Py_None);
1212 assert(x != Py_NotImplemented);
1215 goto exit_result_object;
1218 if (unlikely(obj_result == NULL)) {
1219 goto exit_result_exception;
1221 result = obj_result;
1222 goto exit_result_ok;
1227 exit_result_exception:
1231 return __BINARY_OPERATION_POW_OBJECT_LONG_OBJECT(operand1, operand2);
1234PyObject *BINARY_OPERATION_POW_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
1235 return _BINARY_OPERATION_POW_OBJECT_LONG_OBJECT(operand1, operand2);
1238#if PYTHON_VERSION < 0x300
1240static PyObject *_BINARY_OPERATION_POW_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
1241 CHECK_OBJECT(operand1);
1242 assert(PyInt_CheckExact(operand1));
1243 CHECK_OBJECT(operand2);
1244 assert(PyInt_CheckExact(operand2));
1249#if defined(_MSC_VER)
1250#pragma warning(push)
1251#pragma warning(disable : 4101)
1253 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1254 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1255 NUITKA_MAY_BE_UNUSED
long clong_result;
1256 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1257#if defined(_MSC_VER)
1261 CHECK_OBJECT(operand1);
1262 assert(PyInt_CheckExact(operand1));
1263 CHECK_OBJECT(operand2);
1264 assert(PyInt_CheckExact(operand2));
1266 const long a = PyInt_AS_LONG(operand1);
1267 const long b = PyInt_AS_LONG(operand2);
1271 PyObject *operand1_float = MAKE_FLOAT_FROM_DOUBLE(a);
1272 PyObject *operand2_float = MAKE_FLOAT_FROM_DOUBLE(b);
1274 PyObject *r = _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1_float, operand2_float);
1276 Py_DECREF(operand1_float);
1277 Py_DECREF(operand2_float);
1280 goto exit_result_object;
1289 ix = (
unsigned long)ix * temp;
1293 if (ix / temp != prev) {
1294 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1295 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1297 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1299 Py_DECREF(operand1_long);
1300 Py_DECREF(operand2_long);
1303 goto exit_result_object;
1311 temp = (
unsigned long)temp * temp;
1313 if (prev != 0 && temp / prev != prev) {
1314 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1315 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1317 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1319 Py_DECREF(operand1_long);
1320 Py_DECREF(operand2_long);
1323 goto exit_result_object;
1328 goto exit_result_ok_clong;
1331exit_result_ok_clong:
1332 result = Nuitka_PyInt_FromLong(clong_result);
1333 goto exit_result_ok;
1336 if (unlikely(obj_result == NULL)) {
1337 goto exit_result_exception;
1339 result = obj_result;
1340 goto exit_result_ok;
1345exit_result_exception:
1349PyObject *BINARY_OPERATION_POW_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
1350 return _BINARY_OPERATION_POW_OBJECT_INT_INT(operand1, operand2);
1354#if PYTHON_VERSION < 0x300
1356static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_POW_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
1357 PyTypeObject *type1 = Py_TYPE(operand1);
1359#if defined(_MSC_VER)
1360#pragma warning(push)
1361#pragma warning(disable : 4101)
1363 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1364 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1365#if defined(_MSC_VER)
1370 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_power : NULL;
1371 ternaryfunc slot2 = NULL;
1373 if (!(type1 == &PyInt_Type)) {
1376 slot2 = PyInt_Type.tp_as_number->nb_power;
1378 if (slot1 == slot2) {
1383 if (slot1 != NULL) {
1384 PyObject *x = slot1(operand1, operand2, Py_None);
1386 if (x != Py_NotImplemented) {
1388 goto exit_binary_result_object;
1391 Py_DECREF_IMMORTAL(x);
1394 if (slot2 != NULL) {
1395 PyObject *x = slot2(operand1, operand2, Py_None);
1397 if (x != Py_NotImplemented) {
1399 goto exit_binary_result_object;
1402 Py_DECREF_IMMORTAL(x);
1405#if PYTHON_VERSION < 0x300
1406 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
1408 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1411 PyObject *coerced1 = operand1;
1412 PyObject *coerced2 = operand2;
1414 int err = c1(&coerced1, &coerced2);
1416 if (unlikely(err < 0)) {
1417 goto exit_binary_exception;
1421 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1423 if (likely(mv == NULL)) {
1424 ternaryfunc slot = mv->nb_power;
1426 if (likely(slot != NULL)) {
1427 PyObject *x = slot(coerced1, coerced2, Py_None);
1429 Py_DECREF(coerced1);
1430 Py_DECREF(coerced2);
1433 goto exit_binary_result_object;
1438 Py_DECREF(coerced1);
1439 Py_DECREF(coerced2);
1442 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
1445 PyObject *coerced1 = operand1;
1446 PyObject *coerced2 = operand2;
1448 int err = c2(&coerced2, &coerced1);
1450 if (unlikely(err < 0)) {
1451 goto exit_binary_exception;
1455 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1457 if (likely(mv == NULL)) {
1458 ternaryfunc slot = mv->nb_power;
1460 if (likely(slot != NULL)) {
1461 PyObject *x = slot(coerced1, coerced2, Py_None);
1463 Py_DECREF(coerced1);
1464 Py_DECREF(coerced2);
1467 goto exit_binary_result_object;
1472 Py_DECREF(coerced1);
1473 Py_DECREF(coerced2);
1479 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): '%s' and 'int'", type1->tp_name);
1480 goto exit_binary_exception;
1482exit_binary_result_object:
1485exit_binary_exception:
1488static PyObject *_BINARY_OPERATION_POW_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
1489 CHECK_OBJECT(operand1);
1490 CHECK_OBJECT(operand2);
1491 assert(PyInt_CheckExact(operand2));
1493 PyTypeObject *type1 = Py_TYPE(operand1);
1495 if (type1 == &PyInt_Type) {
1501#if defined(_MSC_VER)
1502#pragma warning(push)
1503#pragma warning(disable : 4101)
1505 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1506 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1507 NUITKA_MAY_BE_UNUSED
long clong_result;
1508 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1509#if defined(_MSC_VER)
1513 CHECK_OBJECT(operand1);
1514 assert(PyInt_CheckExact(operand1));
1515 CHECK_OBJECT(operand2);
1516 assert(PyInt_CheckExact(operand2));
1518 const long a = PyInt_AS_LONG(operand1);
1519 const long b = PyInt_AS_LONG(operand2);
1523 PyObject *operand1_float = MAKE_FLOAT_FROM_DOUBLE(a);
1524 PyObject *operand2_float = MAKE_FLOAT_FROM_DOUBLE(b);
1526 PyObject *r = _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1_float, operand2_float);
1528 Py_DECREF(operand1_float);
1529 Py_DECREF(operand2_float);
1532 goto exit_result_object;
1541 ix = (
unsigned long)ix * temp;
1545 if (ix / temp != prev) {
1546 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1547 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1549 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1551 Py_DECREF(operand1_long);
1552 Py_DECREF(operand2_long);
1555 goto exit_result_object;
1563 temp = (
unsigned long)temp * temp;
1565 if (prev != 0 && temp / prev != prev) {
1566 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1567 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1569 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1571 Py_DECREF(operand1_long);
1572 Py_DECREF(operand2_long);
1575 goto exit_result_object;
1580 goto exit_result_ok_clong;
1583 exit_result_ok_clong:
1584 result = Nuitka_PyInt_FromLong(clong_result);
1585 goto exit_result_ok;
1588 if (unlikely(obj_result == NULL)) {
1589 goto exit_result_exception;
1591 result = obj_result;
1592 goto exit_result_ok;
1597 exit_result_exception:
1601 return __BINARY_OPERATION_POW_OBJECT_OBJECT_INT(operand1, operand2);
1604PyObject *BINARY_OPERATION_POW_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
1605 return _BINARY_OPERATION_POW_OBJECT_OBJECT_INT(operand1, operand2);
1609#if PYTHON_VERSION < 0x300
1611static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_POW_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
1612 PyTypeObject *type2 = Py_TYPE(operand2);
1614#if defined(_MSC_VER)
1615#pragma warning(push)
1616#pragma warning(disable : 4101)
1618 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1619 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1620#if defined(_MSC_VER)
1624 ternaryfunc slot1 = PyInt_Type.tp_as_number->nb_power;
1625 ternaryfunc slot2 = NULL;
1627 if (!(&PyInt_Type == type2)) {
1630 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_power : NULL;
1632 if (slot1 == slot2) {
1637 if (slot1 != NULL) {
1638 if (slot2 != NULL) {
1639 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
1640 PyObject *x = slot2(operand1, operand2, Py_None);
1642 if (x != Py_NotImplemented) {
1644 goto exit_binary_result_object;
1647 Py_DECREF_IMMORTAL(x);
1652 PyObject *x = slot1(operand1, operand2, Py_None);
1654 if (x != Py_NotImplemented) {
1656 goto exit_binary_result_object;
1659 Py_DECREF_IMMORTAL(x);
1662 if (slot2 != NULL) {
1663 PyObject *x = slot2(operand1, operand2, Py_None);
1665 if (x != Py_NotImplemented) {
1667 goto exit_binary_result_object;
1670 Py_DECREF_IMMORTAL(x);
1673#if PYTHON_VERSION < 0x300
1674 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1675 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
1678 PyObject *coerced1 = operand1;
1679 PyObject *coerced2 = operand2;
1681 int err = c1(&coerced1, &coerced2);
1683 if (unlikely(err < 0)) {
1684 goto exit_binary_exception;
1688 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1690 if (likely(mv == NULL)) {
1691 ternaryfunc slot = mv->nb_power;
1693 if (likely(slot != NULL)) {
1694 PyObject *x = slot(coerced1, coerced2, Py_None);
1696 Py_DECREF(coerced1);
1697 Py_DECREF(coerced2);
1700 goto exit_binary_result_object;
1705 Py_DECREF(coerced1);
1706 Py_DECREF(coerced2);
1710 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1713 PyObject *coerced1 = operand1;
1714 PyObject *coerced2 = operand2;
1716 int err = c2(&coerced2, &coerced1);
1718 if (unlikely(err < 0)) {
1719 goto exit_binary_exception;
1723 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1725 if (likely(mv == NULL)) {
1726 ternaryfunc slot = mv->nb_power;
1728 if (likely(slot != NULL)) {
1729 PyObject *x = slot(coerced1, coerced2, Py_None);
1731 Py_DECREF(coerced1);
1732 Py_DECREF(coerced2);
1735 goto exit_binary_result_object;
1740 Py_DECREF(coerced1);
1741 Py_DECREF(coerced2);
1747 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'int' and '%s'", type2->tp_name);
1748 goto exit_binary_exception;
1750exit_binary_result_object:
1753exit_binary_exception:
1756static PyObject *_BINARY_OPERATION_POW_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
1757 CHECK_OBJECT(operand1);
1758 assert(PyInt_CheckExact(operand1));
1759 CHECK_OBJECT(operand2);
1761 PyTypeObject *type2 = Py_TYPE(operand2);
1763 if (&PyInt_Type == type2) {
1769#if defined(_MSC_VER)
1770#pragma warning(push)
1771#pragma warning(disable : 4101)
1773 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1774 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1775 NUITKA_MAY_BE_UNUSED
long clong_result;
1776 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1777#if defined(_MSC_VER)
1781 CHECK_OBJECT(operand1);
1782 assert(PyInt_CheckExact(operand1));
1783 CHECK_OBJECT(operand2);
1784 assert(PyInt_CheckExact(operand2));
1786 const long a = PyInt_AS_LONG(operand1);
1787 const long b = PyInt_AS_LONG(operand2);
1791 PyObject *operand1_float = MAKE_FLOAT_FROM_DOUBLE(a);
1792 PyObject *operand2_float = MAKE_FLOAT_FROM_DOUBLE(b);
1794 PyObject *r = _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1_float, operand2_float);
1796 Py_DECREF(operand1_float);
1797 Py_DECREF(operand2_float);
1800 goto exit_result_object;
1809 ix = (
unsigned long)ix * temp;
1813 if (ix / temp != prev) {
1814 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1815 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1817 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1819 Py_DECREF(operand1_long);
1820 Py_DECREF(operand2_long);
1823 goto exit_result_object;
1831 temp = (
unsigned long)temp * temp;
1833 if (prev != 0 && temp / prev != prev) {
1834 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1835 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1837 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1839 Py_DECREF(operand1_long);
1840 Py_DECREF(operand2_long);
1843 goto exit_result_object;
1848 goto exit_result_ok_clong;
1851 exit_result_ok_clong:
1852 result = Nuitka_PyInt_FromLong(clong_result);
1853 goto exit_result_ok;
1856 if (unlikely(obj_result == NULL)) {
1857 goto exit_result_exception;
1859 result = obj_result;
1860 goto exit_result_ok;
1865 exit_result_exception:
1869 return __BINARY_OPERATION_POW_OBJECT_INT_OBJECT(operand1, operand2);
1872PyObject *BINARY_OPERATION_POW_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
1873 return _BINARY_OPERATION_POW_OBJECT_INT_OBJECT(operand1, operand2);
1878static PyObject *_BINARY_OPERATION_POW_OBJECT_FLOAT_LONG(PyObject *operand1, PyObject *operand2) {
1879 CHECK_OBJECT(operand1);
1880 assert(PyFloat_CheckExact(operand1));
1881 CHECK_OBJECT(operand2);
1882 assert(PyLong_CheckExact(operand2));
1884#if defined(_MSC_VER)
1885#pragma warning(push)
1886#pragma warning(disable : 4101)
1888 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1889 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1890#if defined(_MSC_VER)
1894 ternaryfunc slot1 = PyFloat_Type.tp_as_number->nb_power;
1897 if (slot1 != NULL) {
1898 PyObject *x = slot1(operand1, operand2, Py_None);
1900 if (x != Py_NotImplemented) {
1902 goto exit_binary_result_object;
1905 Py_DECREF_IMMORTAL(x);
1910#if PYTHON_VERSION < 0x300
1911 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'float' and 'long'");
1913 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'float' and 'int'");
1915 goto exit_binary_exception;
1917exit_binary_result_object:
1920exit_binary_exception:
1924PyObject *BINARY_OPERATION_POW_OBJECT_FLOAT_LONG(PyObject *operand1, PyObject *operand2) {
1925 return _BINARY_OPERATION_POW_OBJECT_FLOAT_LONG(operand1, operand2);
1929static PyObject *_BINARY_OPERATION_POW_OBJECT_LONG_FLOAT(PyObject *operand1, PyObject *operand2) {
1930 CHECK_OBJECT(operand1);
1931 assert(PyLong_CheckExact(operand1));
1932 CHECK_OBJECT(operand2);
1933 assert(PyFloat_CheckExact(operand2));
1935#if defined(_MSC_VER)
1936#pragma warning(push)
1937#pragma warning(disable : 4101)
1939 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1940 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1941#if defined(_MSC_VER)
1946 ternaryfunc slot2 = NULL;
1951 slot2 = PyFloat_Type.tp_as_number->nb_power;
1954 if (slot2 != NULL) {
1955 PyObject *x = slot2(operand1, operand2, Py_None);
1957 if (x != Py_NotImplemented) {
1959 goto exit_binary_result_object;
1962 Py_DECREF_IMMORTAL(x);
1967#if PYTHON_VERSION < 0x300
1968 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'long' and 'float'");
1970 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'int' and 'float'");
1972 goto exit_binary_exception;
1974exit_binary_result_object:
1977exit_binary_exception:
1981PyObject *BINARY_OPERATION_POW_OBJECT_LONG_FLOAT(PyObject *operand1, PyObject *operand2) {
1982 return _BINARY_OPERATION_POW_OBJECT_LONG_FLOAT(operand1, operand2);
1985#if PYTHON_VERSION < 0x300
1987static PyObject *_BINARY_OPERATION_POW_OBJECT_FLOAT_INT(PyObject *operand1, PyObject *operand2) {
1988 CHECK_OBJECT(operand1);
1989 assert(PyFloat_CheckExact(operand1));
1990 CHECK_OBJECT(operand2);
1991 assert(PyInt_CheckExact(operand2));
1993#if defined(_MSC_VER)
1994#pragma warning(push)
1995#pragma warning(disable : 4101)
1997 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1998 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1999#if defined(_MSC_VER)
2003 ternaryfunc slot1 = PyFloat_Type.tp_as_number->nb_power;
2006 if (slot1 != NULL) {
2007 PyObject *x = slot1(operand1, operand2, Py_None);
2009 if (x != Py_NotImplemented) {
2011 goto exit_binary_result_object;
2014 Py_DECREF_IMMORTAL(x);
2019 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'float' and 'int'");
2020 goto exit_binary_exception;
2022exit_binary_result_object:
2025exit_binary_exception:
2029PyObject *BINARY_OPERATION_POW_OBJECT_FLOAT_INT(PyObject *operand1, PyObject *operand2) {
2030 return _BINARY_OPERATION_POW_OBJECT_FLOAT_INT(operand1, operand2);
2034#if PYTHON_VERSION < 0x300
2036static PyObject *_BINARY_OPERATION_POW_OBJECT_INT_FLOAT(PyObject *operand1, PyObject *operand2) {
2037 CHECK_OBJECT(operand1);
2038 assert(PyInt_CheckExact(operand1));
2039 CHECK_OBJECT(operand2);
2040 assert(PyFloat_CheckExact(operand2));
2042#if defined(_MSC_VER)
2043#pragma warning(push)
2044#pragma warning(disable : 4101)
2046 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2047 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2048#if defined(_MSC_VER)
2053 ternaryfunc slot2 = NULL;
2058 slot2 = PyFloat_Type.tp_as_number->nb_power;
2061 if (slot2 != NULL) {
2062 PyObject *x = slot2(operand1, operand2, Py_None);
2064 if (x != Py_NotImplemented) {
2066 goto exit_binary_result_object;
2069 Py_DECREF_IMMORTAL(x);
2074 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'int' and 'float'");
2075 goto exit_binary_exception;
2077exit_binary_result_object:
2080exit_binary_exception:
2084PyObject *BINARY_OPERATION_POW_OBJECT_INT_FLOAT(PyObject *operand1, PyObject *operand2) {
2085 return _BINARY_OPERATION_POW_OBJECT_INT_FLOAT(operand1, operand2);
2089#if PYTHON_VERSION < 0x300
2091static PyObject *_BINARY_OPERATION_POW_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
2092 CHECK_OBJECT(operand1);
2093 assert(PyLong_CheckExact(operand1));
2094 CHECK_OBJECT(operand2);
2095 assert(PyInt_CheckExact(operand2));
2097#if defined(_MSC_VER)
2098#pragma warning(push)
2099#pragma warning(disable : 4101)
2101 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2102 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2103#if defined(_MSC_VER)
2107 ternaryfunc slot1 = PyLong_Type.tp_as_number->nb_power;
2110 if (slot1 != NULL) {
2111 PyObject *x = slot1(operand1, operand2, Py_None);
2113 if (x != Py_NotImplemented) {
2115 goto exit_binary_result_object;
2118 Py_DECREF_IMMORTAL(x);
2123 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'long' and 'int'");
2124 goto exit_binary_exception;
2126exit_binary_result_object:
2129exit_binary_exception:
2133PyObject *BINARY_OPERATION_POW_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
2134 return _BINARY_OPERATION_POW_OBJECT_LONG_INT(operand1, operand2);
2138#if PYTHON_VERSION < 0x300
2140static PyObject *_BINARY_OPERATION_POW_OBJECT_INT_LONG(PyObject *operand1, PyObject *operand2) {
2141 CHECK_OBJECT(operand1);
2142 assert(PyInt_CheckExact(operand1));
2143 CHECK_OBJECT(operand2);
2144 assert(PyLong_CheckExact(operand2));
2146#if defined(_MSC_VER)
2147#pragma warning(push)
2148#pragma warning(disable : 4101)
2150 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2151 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2152#if defined(_MSC_VER)
2157 ternaryfunc slot2 = NULL;
2162 slot2 = PyLong_Type.tp_as_number->nb_power;
2165 if (slot2 != NULL) {
2166 PyObject *x = slot2(operand1, operand2, Py_None);
2168 if (x != Py_NotImplemented) {
2170 goto exit_binary_result_object;
2173 Py_DECREF_IMMORTAL(x);
2178 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): 'int' and 'long'");
2179 goto exit_binary_exception;
2181exit_binary_result_object:
2184exit_binary_exception:
2188PyObject *BINARY_OPERATION_POW_OBJECT_INT_LONG(PyObject *operand1, PyObject *operand2) {
2189 return _BINARY_OPERATION_POW_OBJECT_INT_LONG(operand1, operand2);
2194static PyObject *_BINARY_OPERATION_POW_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
2195 CHECK_OBJECT(operand1);
2196 CHECK_OBJECT(operand2);
2198#if PYTHON_VERSION < 0x300
2199 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
2203#if defined(_MSC_VER)
2204#pragma warning(push)
2205#pragma warning(disable : 4101)
2207 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2208 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2209 NUITKA_MAY_BE_UNUSED
long clong_result;
2210 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2211#if defined(_MSC_VER)
2215 CHECK_OBJECT(operand1);
2216 assert(PyInt_CheckExact(operand1));
2217 CHECK_OBJECT(operand2);
2218 assert(PyInt_CheckExact(operand2));
2220 const long a = PyInt_AS_LONG(operand1);
2221 const long b = PyInt_AS_LONG(operand2);
2225 PyObject *operand1_float = MAKE_FLOAT_FROM_DOUBLE(a);
2226 PyObject *operand2_float = MAKE_FLOAT_FROM_DOUBLE(b);
2228 PyObject *r = _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1_float, operand2_float);
2230 Py_DECREF(operand1_float);
2231 Py_DECREF(operand2_float);
2234 goto exit_result_object;
2243 ix = (
unsigned long)ix * temp;
2247 if (ix / temp != prev) {
2248 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
2249 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
2251 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
2253 Py_DECREF(operand1_long);
2254 Py_DECREF(operand2_long);
2257 goto exit_result_object;
2265 temp = (
unsigned long)temp * temp;
2267 if (prev != 0 && temp / prev != prev) {
2268 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
2269 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
2271 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
2273 Py_DECREF(operand1_long);
2274 Py_DECREF(operand2_long);
2277 goto exit_result_object;
2282 goto exit_result_ok_clong;
2285 exit_result_ok_clong:
2286 result = Nuitka_PyInt_FromLong(clong_result);
2287 goto exit_result_ok;
2290 if (unlikely(obj_result == NULL)) {
2291 goto exit_result_exception;
2293 result = obj_result;
2294 goto exit_result_ok;
2299 exit_result_exception:
2304 PyTypeObject *type1 = Py_TYPE(operand1);
2305 PyTypeObject *type2 = Py_TYPE(operand2);
2307#if defined(_MSC_VER)
2308#pragma warning(push)
2309#pragma warning(disable : 4101)
2311 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2312 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2313#if defined(_MSC_VER)
2318 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_power : NULL;
2319 ternaryfunc slot2 = NULL;
2321 if (!(type1 == type2)) {
2324 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_power : NULL;
2326 if (slot1 == slot2) {
2331 if (slot1 != NULL) {
2332 if (slot2 != NULL) {
2333 if (Nuitka_Type_IsSubtype(type2, type1)) {
2334 PyObject *x = slot2(operand1, operand2, Py_None);
2336 if (x != Py_NotImplemented) {
2338 goto exit_binary_result_object;
2341 Py_DECREF_IMMORTAL(x);
2346 PyObject *x = slot1(operand1, operand2, Py_None);
2348 if (x != Py_NotImplemented) {
2350 goto exit_binary_result_object;
2353 Py_DECREF_IMMORTAL(x);
2356 if (slot2 != NULL) {
2357 PyObject *x = slot2(operand1, operand2, Py_None);
2359 if (x != Py_NotImplemented) {
2361 goto exit_binary_result_object;
2364 Py_DECREF_IMMORTAL(x);
2367#if PYTHON_VERSION < 0x300
2368 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
2370 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
2373 PyObject *coerced1 = operand1;
2374 PyObject *coerced2 = operand2;
2376 int err = c1(&coerced1, &coerced2);
2378 if (unlikely(err < 0)) {
2379 goto exit_binary_exception;
2383 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2385 if (likely(mv == NULL)) {
2386 ternaryfunc slot = mv->nb_power;
2388 if (likely(slot != NULL)) {
2389 PyObject *x = slot(coerced1, coerced2, Py_None);
2391 Py_DECREF(coerced1);
2392 Py_DECREF(coerced2);
2395 goto exit_binary_result_object;
2400 Py_DECREF(coerced1);
2401 Py_DECREF(coerced2);
2405 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
2408 PyObject *coerced1 = operand1;
2409 PyObject *coerced2 = operand2;
2411 int err = c2(&coerced2, &coerced1);
2413 if (unlikely(err < 0)) {
2414 goto exit_binary_exception;
2418 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2420 if (likely(mv == NULL)) {
2421 ternaryfunc slot = mv->nb_power;
2423 if (likely(slot != NULL)) {
2424 PyObject *x = slot(coerced1, coerced2, Py_None);
2426 Py_DECREF(coerced1);
2427 Py_DECREF(coerced2);
2430 goto exit_binary_result_object;
2435 Py_DECREF(coerced1);
2436 Py_DECREF(coerced2);
2442 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): '%s' and '%s'", type1->tp_name,
2444 goto exit_binary_exception;
2446exit_binary_result_object:
2449exit_binary_exception:
2453PyObject *BINARY_OPERATION_POW_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
2454 return _BINARY_OPERATION_POW_OBJECT_OBJECT_OBJECT(operand1, operand2);
2458static nuitka_bool _BINARY_OPERATION_POW_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
2459 CHECK_OBJECT(operand1);
2460 CHECK_OBJECT(operand2);
2462#if PYTHON_VERSION < 0x300
2463 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
2467#if defined(_MSC_VER)
2468#pragma warning(push)
2469#pragma warning(disable : 4101)
2471 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2472 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2473 NUITKA_MAY_BE_UNUSED
long clong_result;
2474 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2475#if defined(_MSC_VER)
2479 CHECK_OBJECT(operand1);
2480 assert(PyInt_CheckExact(operand1));
2481 CHECK_OBJECT(operand2);
2482 assert(PyInt_CheckExact(operand2));
2484 const long a = PyInt_AS_LONG(operand1);
2485 const long b = PyInt_AS_LONG(operand2);
2489 PyObject *operand1_float = MAKE_FLOAT_FROM_DOUBLE(a);
2490 PyObject *operand2_float = MAKE_FLOAT_FROM_DOUBLE(b);
2492 PyObject *r = _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1_float, operand2_float);
2494 Py_DECREF(operand1_float);
2495 Py_DECREF(operand2_float);
2498 goto exit_result_object;
2507 ix = (
unsigned long)ix * temp;
2511 if (ix / temp != prev) {
2512 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
2513 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
2515 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
2517 Py_DECREF(operand1_long);
2518 Py_DECREF(operand2_long);
2521 goto exit_result_object;
2529 temp = (
unsigned long)temp * temp;
2531 if (prev != 0 && temp / prev != prev) {
2532 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
2533 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
2535 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
2537 Py_DECREF(operand1_long);
2538 Py_DECREF(operand2_long);
2541 goto exit_result_object;
2546 goto exit_result_ok_clong;
2549 exit_result_ok_clong:
2550 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2551 goto exit_result_ok;
2554 if (unlikely(obj_result == NULL)) {
2555 goto exit_result_exception;
2557 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2558 Py_DECREF(obj_result);
2559 goto exit_result_ok;
2564 exit_result_exception:
2565 return NUITKA_BOOL_EXCEPTION;
2569 PyTypeObject *type1 = Py_TYPE(operand1);
2570 PyTypeObject *type2 = Py_TYPE(operand2);
2572#if defined(_MSC_VER)
2573#pragma warning(push)
2574#pragma warning(disable : 4101)
2576 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2577 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2578#if defined(_MSC_VER)
2583 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_power : NULL;
2584 ternaryfunc slot2 = NULL;
2586 if (!(type1 == type2)) {
2589 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_power : NULL;
2591 if (slot1 == slot2) {
2596 if (slot1 != NULL) {
2597 if (slot2 != NULL) {
2598 if (Nuitka_Type_IsSubtype(type2, type1)) {
2599 PyObject *x = slot2(operand1, operand2, Py_None);
2601 if (x != Py_NotImplemented) {
2603 goto exit_binary_result_object;
2606 Py_DECREF_IMMORTAL(x);
2611 PyObject *x = slot1(operand1, operand2, Py_None);
2613 if (x != Py_NotImplemented) {
2615 goto exit_binary_result_object;
2618 Py_DECREF_IMMORTAL(x);
2621 if (slot2 != NULL) {
2622 PyObject *x = slot2(operand1, operand2, Py_None);
2624 if (x != Py_NotImplemented) {
2626 goto exit_binary_result_object;
2629 Py_DECREF_IMMORTAL(x);
2632#if PYTHON_VERSION < 0x300
2633 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
2635 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
2638 PyObject *coerced1 = operand1;
2639 PyObject *coerced2 = operand2;
2641 int err = c1(&coerced1, &coerced2);
2643 if (unlikely(err < 0)) {
2644 goto exit_binary_exception;
2648 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2650 if (likely(mv == NULL)) {
2651 ternaryfunc slot = mv->nb_power;
2653 if (likely(slot != NULL)) {
2654 PyObject *x = slot(coerced1, coerced2, Py_None);
2656 Py_DECREF(coerced1);
2657 Py_DECREF(coerced2);
2660 goto exit_binary_result_object;
2665 Py_DECREF(coerced1);
2666 Py_DECREF(coerced2);
2670 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
2673 PyObject *coerced1 = operand1;
2674 PyObject *coerced2 = operand2;
2676 int err = c2(&coerced2, &coerced1);
2678 if (unlikely(err < 0)) {
2679 goto exit_binary_exception;
2683 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2685 if (likely(mv == NULL)) {
2686 ternaryfunc slot = mv->nb_power;
2688 if (likely(slot != NULL)) {
2689 PyObject *x = slot(coerced1, coerced2, Py_None);
2691 Py_DECREF(coerced1);
2692 Py_DECREF(coerced2);
2695 goto exit_binary_result_object;
2700 Py_DECREF(coerced1);
2701 Py_DECREF(coerced2);
2707 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for ** or pow(): '%s' and '%s'", type1->tp_name,
2709 goto exit_binary_exception;
2711exit_binary_result_object:
2712 if (unlikely(obj_result == NULL)) {
2713 return NUITKA_BOOL_EXCEPTION;
2717 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2718 Py_DECREF(obj_result);
2722exit_binary_exception:
2723 return NUITKA_BOOL_EXCEPTION;
2726nuitka_bool BINARY_OPERATION_POW_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
2727 return _BINARY_OPERATION_POW_NBOOL_OBJECT_OBJECT(operand1, operand2);