7#include "nuitka/prelude.h"
13static inline bool _INPLACE_OPERATION_POW_FLOAT_FLOAT(PyObject **operand1, PyObject *operand2) {
16 CHECK_OBJECT(*operand1);
17 assert(PyFloat_CheckExact(*operand1));
18 CHECK_OBJECT(operand2);
19 assert(PyFloat_CheckExact(operand2));
23#pragma warning(disable : 4101)
26 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
27 NUITKA_MAY_BE_UNUSED
long clong_result;
28 NUITKA_MAY_BE_UNUSED
double cfloat_result;
33 CHECK_OBJECT(*operand1);
34 assert(PyFloat_CheckExact(*operand1));
35 CHECK_OBJECT(operand2);
36 assert(PyFloat_CheckExact(operand2));
38 double a = PyFloat_AS_DOUBLE(*operand1);
39 const double b = PyFloat_AS_DOUBLE(operand2);
42 goto exit_result_ok_const_float_1_0;
46 goto exit_result_ok_left;
51 goto exit_result_ok_const_float_1_0;
53 goto exit_result_ok_right;
57 if (Py_IS_INFINITY(b)) {
60 goto exit_result_ok_const_float_1_0;
61 }
else if ((b > 0.0) == (a > 1.0)) {
62 long r = (long)fabs(b);
65 goto exit_result_ok_cfloat;
67 goto exit_result_ok_const_float_0_0;
71 if (Py_IS_INFINITY(a)) {
72 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
76 r = b_is_odd ? a : fabs(a);
78 r = b_is_odd ? copysign(0.0, a) : 0.0;
82 goto exit_result_ok_cfloat;
86 if (unlikely(b < 0.0)) {
87 PyThreadState *tstate = PyThreadState_GET();
89 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
90 "0.0 cannot be raised to a negative power");
91 goto exit_result_exception;
94 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
95 double r = b_is_odd ? a : 0.0;
98 goto exit_result_ok_cfloat;
102 bool negate_result =
false;
105 if (unlikely(b != floor(b))) {
106 PyThreadState *tstate = PyThreadState_GET();
108 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
109 "negative number cannot be raised to a fractional power");
110 goto exit_result_exception;
114 negate_result = DOUBLE_IS_ODD_INTEGER(b);
119 goto exit_result_ok_const_float_minus_1_0;
121 goto exit_result_ok_const_float_1_0;
125 double r = pow(a, b);
127 if (unlikely(errno != 0)) {
128 PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : PyExc_ValueError);
129 goto exit_result_exception;
132 r = negate_result ? -r : r;
135 goto exit_result_ok_cfloat;
139exit_result_ok_cfloat:
140 if (Py_REFCNT(*operand1) == 1) {
141 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
144 Py_DECREF(*operand1);
146 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
155 Py_DECREF(*operand1);
156 *operand1 = operand2;
159exit_result_ok_const_float_0_0:
161 Py_DECREF(*operand1);
162 *operand1 = MAKE_FLOAT_FROM_DOUBLE(0.0);
165exit_result_ok_const_float_1_0:
167 Py_DECREF(*operand1);
168 *operand1 = MAKE_FLOAT_FROM_DOUBLE(1.0);
171exit_result_ok_const_float_minus_1_0:
173 Py_DECREF(*operand1);
174 *operand1 = MAKE_FLOAT_FROM_DOUBLE(-1.0);
180exit_result_exception:
184bool INPLACE_OPERATION_POW_FLOAT_FLOAT(PyObject **operand1, PyObject *operand2) {
185 return _INPLACE_OPERATION_POW_FLOAT_FLOAT(operand1, operand2);
189static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_POW_OBJECT_FLOAT(PyObject **operand1, PyObject *operand2) {
190 PyTypeObject *type1 = Py_TYPE(*operand1);
194#pragma warning(disable : 4101)
196 NUITKA_MAY_BE_UNUSED
bool cbool_result;
197 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
203 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_power : NULL;
206 PyObject *x = islot(*operand1, operand2, Py_None);
208 if (x != Py_NotImplemented) {
210 goto exit_inplace_result_object;
213 Py_DECREF_IMMORTAL(x);
218 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_power : NULL;
219 ternaryfunc slot2 = NULL;
221 if (!(type1 == &PyFloat_Type)) {
224 slot2 = PyFloat_Type.tp_as_number->nb_power;
226 if (slot1 == slot2) {
232 PyObject *x = slot1(*operand1, operand2, Py_None);
234 if (x != Py_NotImplemented) {
236 goto exit_inplace_result_object;
239 Py_DECREF_IMMORTAL(x);
243 PyObject *x = slot2(*operand1, operand2, Py_None);
245 if (x != Py_NotImplemented) {
247 goto exit_inplace_result_object;
250 Py_DECREF_IMMORTAL(x);
253#if PYTHON_VERSION < 0x300
254 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
256 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
259 PyObject *coerced1 = *operand1;
260 PyObject *coerced2 = operand2;
262 int err = c1(&coerced1, &coerced2);
264 if (unlikely(err < 0)) {
265 goto exit_inplace_exception;
269 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
271 if (likely(mv == NULL)) {
272 ternaryfunc slot = mv->nb_power;
274 if (likely(slot != NULL)) {
275 PyObject *x = slot(coerced1, coerced2, Py_None);
281 goto exit_inplace_result_object;
290 coercion c2 = PyFloat_Type.tp_as_number->nb_coerce;
293 PyObject *coerced1 = *operand1;
294 PyObject *coerced2 = operand2;
296 int err = c2(&coerced2, &coerced1);
298 if (unlikely(err < 0)) {
299 goto exit_inplace_exception;
303 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
305 if (likely(mv == NULL)) {
306 ternaryfunc slot = mv->nb_power;
308 if (likely(slot != NULL)) {
309 PyObject *x = slot(coerced1, coerced2, Py_None);
315 goto exit_inplace_result_object;
327 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: '%s' and 'float'", type1->tp_name);
328 goto exit_inplace_exception;
331exit_inplace_result_object:
332 if (unlikely(obj_result == NULL)) {
337 Py_DECREF(*operand1);
341 *operand1 = obj_result;
345exit_inplace_exception:
348static inline bool _INPLACE_OPERATION_POW_OBJECT_FLOAT(PyObject **operand1, PyObject *operand2) {
351 CHECK_OBJECT(*operand1);
352 CHECK_OBJECT(operand2);
353 assert(PyFloat_CheckExact(operand2));
355 PyTypeObject *type1 = Py_TYPE(*operand1);
357 if (type1 == &PyFloat_Type) {
362#pragma warning(disable : 4101)
365 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
366 NUITKA_MAY_BE_UNUSED
long clong_result;
367 NUITKA_MAY_BE_UNUSED
double cfloat_result;
372 CHECK_OBJECT(*operand1);
373 assert(PyFloat_CheckExact(*operand1));
374 CHECK_OBJECT(operand2);
375 assert(PyFloat_CheckExact(operand2));
377 double a = PyFloat_AS_DOUBLE(*operand1);
378 const double b = PyFloat_AS_DOUBLE(operand2);
381 goto exit_result_ok_const_float_1_0;
385 goto exit_result_ok_left;
390 goto exit_result_ok_const_float_1_0;
392 goto exit_result_ok_right;
396 if (Py_IS_INFINITY(b)) {
399 goto exit_result_ok_const_float_1_0;
400 }
else if ((b > 0.0) == (a > 1.0)) {
401 long r = (long)fabs(b);
404 goto exit_result_ok_cfloat;
406 goto exit_result_ok_const_float_0_0;
410 if (Py_IS_INFINITY(a)) {
411 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
415 r = b_is_odd ? a : fabs(a);
417 r = b_is_odd ? copysign(0.0, a) : 0.0;
421 goto exit_result_ok_cfloat;
425 if (unlikely(b < 0.0)) {
426 PyThreadState *tstate = PyThreadState_GET();
428 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
429 "0.0 cannot be raised to a negative power");
430 goto exit_result_exception;
433 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
434 double r = b_is_odd ? a : 0.0;
437 goto exit_result_ok_cfloat;
441 bool negate_result =
false;
444 if (unlikely(b != floor(b))) {
445 PyThreadState *tstate = PyThreadState_GET();
447 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
448 "negative number cannot be raised to a fractional power");
449 goto exit_result_exception;
453 negate_result = DOUBLE_IS_ODD_INTEGER(b);
458 goto exit_result_ok_const_float_minus_1_0;
460 goto exit_result_ok_const_float_1_0;
464 double r = pow(a, b);
466 if (unlikely(errno != 0)) {
467 PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : PyExc_ValueError);
468 goto exit_result_exception;
471 r = negate_result ? -r : r;
474 goto exit_result_ok_cfloat;
478 exit_result_ok_cfloat:
479 if (Py_REFCNT(*operand1) == 1) {
480 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
483 Py_DECREF(*operand1);
485 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
492 exit_result_ok_right:
494 Py_DECREF(*operand1);
495 *operand1 = operand2;
498 exit_result_ok_const_float_0_0:
500 Py_DECREF(*operand1);
501 *operand1 = MAKE_FLOAT_FROM_DOUBLE(0.0);
504 exit_result_ok_const_float_1_0:
506 Py_DECREF(*operand1);
507 *operand1 = MAKE_FLOAT_FROM_DOUBLE(1.0);
510 exit_result_ok_const_float_minus_1_0:
512 Py_DECREF(*operand1);
513 *operand1 = MAKE_FLOAT_FROM_DOUBLE(-1.0);
519 exit_result_exception:
523 return __INPLACE_OPERATION_POW_OBJECT_FLOAT(operand1, operand2);
526bool INPLACE_OPERATION_POW_OBJECT_FLOAT(PyObject **operand1, PyObject *operand2) {
527 return _INPLACE_OPERATION_POW_OBJECT_FLOAT(operand1, operand2);
531static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_POW_FLOAT_OBJECT(PyObject **operand1, PyObject *operand2) {
532 PyTypeObject *type2 = Py_TYPE(operand2);
536#pragma warning(disable : 4101)
538 NUITKA_MAY_BE_UNUSED
bool cbool_result;
539 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
547 ternaryfunc slot1 = PyFloat_Type.tp_as_number->nb_power;
548 ternaryfunc slot2 = NULL;
550 if (!(&PyFloat_Type == type2)) {
554 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_power : NULL;
556 if (slot1 == slot2) {
563 if (Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
564 PyObject *x = slot2(*operand1, operand2, Py_None);
566 if (x != Py_NotImplemented) {
568 goto exit_inplace_result_object;
571 Py_DECREF_IMMORTAL(x);
576 PyObject *x = slot1(*operand1, operand2, Py_None);
578 if (x != Py_NotImplemented) {
580 goto exit_inplace_result_object;
583 Py_DECREF_IMMORTAL(x);
587 PyObject *x = slot2(*operand1, operand2, Py_None);
589 if (x != Py_NotImplemented) {
591 goto exit_inplace_result_object;
594 Py_DECREF_IMMORTAL(x);
597#if PYTHON_VERSION < 0x300
598 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
599 coercion c1 = PyFloat_Type.tp_as_number->nb_coerce;
602 PyObject *coerced1 = *operand1;
603 PyObject *coerced2 = operand2;
605 int err = c1(&coerced1, &coerced2);
607 if (unlikely(err < 0)) {
608 goto exit_inplace_exception;
612 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
614 if (likely(mv == NULL)) {
615 ternaryfunc slot = mv->nb_power;
617 if (likely(slot != NULL)) {
618 PyObject *x = slot(coerced1, coerced2, Py_None);
624 goto exit_inplace_result_object;
634 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
637 PyObject *coerced1 = *operand1;
638 PyObject *coerced2 = operand2;
640 int err = c2(&coerced2, &coerced1);
642 if (unlikely(err < 0)) {
643 goto exit_inplace_exception;
647 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
649 if (likely(mv == NULL)) {
650 ternaryfunc slot = mv->nb_power;
652 if (likely(slot != NULL)) {
653 PyObject *x = slot(coerced1, coerced2, Py_None);
659 goto exit_inplace_result_object;
671 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'float' and '%s'", type2->tp_name);
672 goto exit_inplace_exception;
675exit_inplace_result_object:
676 if (unlikely(obj_result == NULL)) {
681 Py_DECREF(*operand1);
685 *operand1 = obj_result;
689exit_inplace_exception:
692static inline bool _INPLACE_OPERATION_POW_FLOAT_OBJECT(PyObject **operand1, PyObject *operand2) {
695 CHECK_OBJECT(*operand1);
696 assert(PyFloat_CheckExact(*operand1));
697 CHECK_OBJECT(operand2);
699 PyTypeObject *type2 = Py_TYPE(operand2);
701 if (&PyFloat_Type == type2) {
706#pragma warning(disable : 4101)
709 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
710 NUITKA_MAY_BE_UNUSED
long clong_result;
711 NUITKA_MAY_BE_UNUSED
double cfloat_result;
716 CHECK_OBJECT(*operand1);
717 assert(PyFloat_CheckExact(*operand1));
718 CHECK_OBJECT(operand2);
719 assert(PyFloat_CheckExact(operand2));
721 double a = PyFloat_AS_DOUBLE(*operand1);
722 const double b = PyFloat_AS_DOUBLE(operand2);
725 goto exit_result_ok_const_float_1_0;
729 goto exit_result_ok_left;
734 goto exit_result_ok_const_float_1_0;
736 goto exit_result_ok_right;
740 if (Py_IS_INFINITY(b)) {
743 goto exit_result_ok_const_float_1_0;
744 }
else if ((b > 0.0) == (a > 1.0)) {
745 long r = (long)fabs(b);
748 goto exit_result_ok_cfloat;
750 goto exit_result_ok_const_float_0_0;
754 if (Py_IS_INFINITY(a)) {
755 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
759 r = b_is_odd ? a : fabs(a);
761 r = b_is_odd ? copysign(0.0, a) : 0.0;
765 goto exit_result_ok_cfloat;
769 if (unlikely(b < 0.0)) {
770 PyThreadState *tstate = PyThreadState_GET();
772 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
773 "0.0 cannot be raised to a negative power");
774 goto exit_result_exception;
777 bool b_is_odd = DOUBLE_IS_ODD_INTEGER(b);
778 double r = b_is_odd ? a : 0.0;
781 goto exit_result_ok_cfloat;
785 bool negate_result =
false;
788 if (unlikely(b != floor(b))) {
789 PyThreadState *tstate = PyThreadState_GET();
791 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
792 "negative number cannot be raised to a fractional power");
793 goto exit_result_exception;
797 negate_result = DOUBLE_IS_ODD_INTEGER(b);
802 goto exit_result_ok_const_float_minus_1_0;
804 goto exit_result_ok_const_float_1_0;
808 double r = pow(a, b);
810 if (unlikely(errno != 0)) {
811 PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : PyExc_ValueError);
812 goto exit_result_exception;
815 r = negate_result ? -r : r;
818 goto exit_result_ok_cfloat;
822 exit_result_ok_cfloat:
823 if (Py_REFCNT(*operand1) == 1) {
824 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
827 Py_DECREF(*operand1);
829 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
836 exit_result_ok_right:
838 Py_DECREF(*operand1);
839 *operand1 = operand2;
842 exit_result_ok_const_float_0_0:
844 Py_DECREF(*operand1);
845 *operand1 = MAKE_FLOAT_FROM_DOUBLE(0.0);
848 exit_result_ok_const_float_1_0:
850 Py_DECREF(*operand1);
851 *operand1 = MAKE_FLOAT_FROM_DOUBLE(1.0);
854 exit_result_ok_const_float_minus_1_0:
856 Py_DECREF(*operand1);
857 *operand1 = MAKE_FLOAT_FROM_DOUBLE(-1.0);
863 exit_result_exception:
867 return __INPLACE_OPERATION_POW_FLOAT_OBJECT(operand1, operand2);
870bool INPLACE_OPERATION_POW_FLOAT_OBJECT(PyObject **operand1, PyObject *operand2) {
871 return _INPLACE_OPERATION_POW_FLOAT_OBJECT(operand1, operand2);
875static inline bool _INPLACE_OPERATION_POW_LONG_LONG(PyObject **operand1, PyObject *operand2) {
878 CHECK_OBJECT(*operand1);
879 assert(PyLong_CheckExact(*operand1));
880 CHECK_OBJECT(operand2);
881 assert(PyLong_CheckExact(operand2));
886#pragma warning(disable : 4101)
888 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
889 NUITKA_MAY_BE_UNUSED
long clong_result;
894 PyObject *x = PyLong_Type.tp_as_number->nb_power(*operand1, operand2, Py_None);
895 assert(x != Py_NotImplemented);
898 goto exit_result_object;
901 if (unlikely(obj_result == NULL)) {
902 goto exit_result_exception;
905 Py_DECREF(*operand1);
906 *operand1 = obj_result;
912exit_result_exception:
916bool INPLACE_OPERATION_POW_LONG_LONG(PyObject **operand1, PyObject *operand2) {
917 return _INPLACE_OPERATION_POW_LONG_LONG(operand1, operand2);
921static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_POW_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
922 PyTypeObject *type1 = Py_TYPE(*operand1);
926#pragma warning(disable : 4101)
928 NUITKA_MAY_BE_UNUSED
bool cbool_result;
929 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
935 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_power : NULL;
938 PyObject *x = islot(*operand1, operand2, Py_None);
940 if (x != Py_NotImplemented) {
942 goto exit_inplace_result_object;
945 Py_DECREF_IMMORTAL(x);
950 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_power : NULL;
951 ternaryfunc slot2 = NULL;
953 if (!(type1 == &PyLong_Type)) {
956 slot2 = PyLong_Type.tp_as_number->nb_power;
958 if (slot1 == slot2) {
964 PyObject *x = slot1(*operand1, operand2, Py_None);
966 if (x != Py_NotImplemented) {
968 goto exit_inplace_result_object;
971 Py_DECREF_IMMORTAL(x);
975 PyObject *x = slot2(*operand1, operand2, Py_None);
977 if (x != Py_NotImplemented) {
979 goto exit_inplace_result_object;
982 Py_DECREF_IMMORTAL(x);
985#if PYTHON_VERSION < 0x300
986 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
988 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
991 PyObject *coerced1 = *operand1;
992 PyObject *coerced2 = operand2;
994 int err = c1(&coerced1, &coerced2);
996 if (unlikely(err < 0)) {
997 goto exit_inplace_exception;
1001 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1003 if (likely(mv == NULL)) {
1004 ternaryfunc slot = mv->nb_power;
1006 if (likely(slot != NULL)) {
1007 PyObject *x = slot(coerced1, coerced2, Py_None);
1009 Py_DECREF(coerced1);
1010 Py_DECREF(coerced2);
1013 goto exit_inplace_result_object;
1018 Py_DECREF(coerced1);
1019 Py_DECREF(coerced2);
1022 coercion c2 = PyLong_Type.tp_as_number->nb_coerce;
1025 PyObject *coerced1 = *operand1;
1026 PyObject *coerced2 = operand2;
1028 int err = c2(&coerced2, &coerced1);
1030 if (unlikely(err < 0)) {
1031 goto exit_inplace_exception;
1035 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1037 if (likely(mv == NULL)) {
1038 ternaryfunc slot = mv->nb_power;
1040 if (likely(slot != NULL)) {
1041 PyObject *x = slot(coerced1, coerced2, Py_None);
1043 Py_DECREF(coerced1);
1044 Py_DECREF(coerced2);
1047 goto exit_inplace_result_object;
1052 Py_DECREF(coerced1);
1053 Py_DECREF(coerced2);
1059#if PYTHON_VERSION < 0x300
1060 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: '%s' and 'long'", type1->tp_name);
1062 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: '%s' and 'int'", type1->tp_name);
1064 goto exit_inplace_exception;
1067exit_inplace_result_object:
1068 if (unlikely(obj_result == NULL)) {
1073 Py_DECREF(*operand1);
1077 *operand1 = obj_result;
1081exit_inplace_exception:
1084static inline bool _INPLACE_OPERATION_POW_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
1087 CHECK_OBJECT(*operand1);
1088 CHECK_OBJECT(operand2);
1089 assert(PyLong_CheckExact(operand2));
1091 PyTypeObject *type1 = Py_TYPE(*operand1);
1093 if (type1 == &PyLong_Type) {
1097#if defined(_MSC_VER)
1098#pragma warning(push)
1099#pragma warning(disable : 4101)
1101 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1102 NUITKA_MAY_BE_UNUSED
long clong_result;
1103#if defined(_MSC_VER)
1107 PyObject *x = PyLong_Type.tp_as_number->nb_power(*operand1, operand2, Py_None);
1108 assert(x != Py_NotImplemented);
1111 goto exit_result_object;
1114 if (unlikely(obj_result == NULL)) {
1115 goto exit_result_exception;
1118 Py_DECREF(*operand1);
1119 *operand1 = obj_result;
1120 goto exit_result_ok;
1125 exit_result_exception:
1129 return __INPLACE_OPERATION_POW_OBJECT_LONG(operand1, operand2);
1132bool INPLACE_OPERATION_POW_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
1133 return _INPLACE_OPERATION_POW_OBJECT_LONG(operand1, operand2);
1137static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_POW_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
1138 PyTypeObject *type2 = Py_TYPE(operand2);
1140#if defined(_MSC_VER)
1141#pragma warning(push)
1142#pragma warning(disable : 4101)
1144 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1145 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1146#if defined(_MSC_VER)
1153 ternaryfunc slot1 = PyLong_Type.tp_as_number->nb_power;
1154 ternaryfunc slot2 = NULL;
1156 if (!(&PyLong_Type == type2)) {
1160 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_power : NULL;
1162 if (slot1 == slot2) {
1167 if (slot1 != NULL) {
1168 if (slot2 != NULL) {
1169 if (Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
1170 PyObject *x = slot2(*operand1, operand2, Py_None);
1172 if (x != Py_NotImplemented) {
1174 goto exit_inplace_result_object;
1177 Py_DECREF_IMMORTAL(x);
1182 PyObject *x = slot1(*operand1, operand2, Py_None);
1184 if (x != Py_NotImplemented) {
1186 goto exit_inplace_result_object;
1189 Py_DECREF_IMMORTAL(x);
1192 if (slot2 != NULL) {
1193 PyObject *x = slot2(*operand1, operand2, Py_None);
1195 if (x != Py_NotImplemented) {
1197 goto exit_inplace_result_object;
1200 Py_DECREF_IMMORTAL(x);
1203#if PYTHON_VERSION < 0x300
1204 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1205 coercion c1 = PyLong_Type.tp_as_number->nb_coerce;
1208 PyObject *coerced1 = *operand1;
1209 PyObject *coerced2 = operand2;
1211 int err = c1(&coerced1, &coerced2);
1213 if (unlikely(err < 0)) {
1214 goto exit_inplace_exception;
1218 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1220 if (likely(mv == NULL)) {
1221 ternaryfunc slot = mv->nb_power;
1223 if (likely(slot != NULL)) {
1224 PyObject *x = slot(coerced1, coerced2, Py_None);
1226 Py_DECREF(coerced1);
1227 Py_DECREF(coerced2);
1230 goto exit_inplace_result_object;
1235 Py_DECREF(coerced1);
1236 Py_DECREF(coerced2);
1240 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1243 PyObject *coerced1 = *operand1;
1244 PyObject *coerced2 = operand2;
1246 int err = c2(&coerced2, &coerced1);
1248 if (unlikely(err < 0)) {
1249 goto exit_inplace_exception;
1253 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1255 if (likely(mv == NULL)) {
1256 ternaryfunc slot = mv->nb_power;
1258 if (likely(slot != NULL)) {
1259 PyObject *x = slot(coerced1, coerced2, Py_None);
1261 Py_DECREF(coerced1);
1262 Py_DECREF(coerced2);
1265 goto exit_inplace_result_object;
1270 Py_DECREF(coerced1);
1271 Py_DECREF(coerced2);
1277#if PYTHON_VERSION < 0x300
1278 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'long' and '%s'", type2->tp_name);
1280 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'int' and '%s'", type2->tp_name);
1282 goto exit_inplace_exception;
1285exit_inplace_result_object:
1286 if (unlikely(obj_result == NULL)) {
1291 Py_DECREF(*operand1);
1295 *operand1 = obj_result;
1299exit_inplace_exception:
1302static inline bool _INPLACE_OPERATION_POW_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
1305 CHECK_OBJECT(*operand1);
1306 assert(PyLong_CheckExact(*operand1));
1307 CHECK_OBJECT(operand2);
1309 PyTypeObject *type2 = Py_TYPE(operand2);
1311 if (&PyLong_Type == type2) {
1315#if defined(_MSC_VER)
1316#pragma warning(push)
1317#pragma warning(disable : 4101)
1319 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1320 NUITKA_MAY_BE_UNUSED
long clong_result;
1321#if defined(_MSC_VER)
1325 PyObject *x = PyLong_Type.tp_as_number->nb_power(*operand1, operand2, Py_None);
1326 assert(x != Py_NotImplemented);
1329 goto exit_result_object;
1332 if (unlikely(obj_result == NULL)) {
1333 goto exit_result_exception;
1336 Py_DECREF(*operand1);
1337 *operand1 = obj_result;
1338 goto exit_result_ok;
1343 exit_result_exception:
1347 return __INPLACE_OPERATION_POW_LONG_OBJECT(operand1, operand2);
1350bool INPLACE_OPERATION_POW_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
1351 return _INPLACE_OPERATION_POW_LONG_OBJECT(operand1, operand2);
1354#if PYTHON_VERSION < 0x300
1356static inline bool _INPLACE_OPERATION_POW_INT_INT(PyObject **operand1, PyObject *operand2) {
1359 CHECK_OBJECT(*operand1);
1360 assert(PyInt_CheckExact(*operand1));
1361 CHECK_OBJECT(operand2);
1362 assert(PyInt_CheckExact(operand2));
1365#if defined(_MSC_VER)
1366#pragma warning(push)
1367#pragma warning(disable : 4101)
1369 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1370 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1371 NUITKA_MAY_BE_UNUSED
long clong_result;
1372 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1373#if defined(_MSC_VER)
1377 CHECK_OBJECT(*operand1);
1378 assert(PyInt_CheckExact(*operand1));
1379 CHECK_OBJECT(operand2);
1380 assert(PyInt_CheckExact(operand2));
1382 const long a = PyInt_AS_LONG(*operand1);
1383 const long b = PyInt_AS_LONG(operand2);
1387 PyObject *operand1_float = MAKE_FLOAT_FROM_DOUBLE(a);
1388 PyObject *operand2_float = MAKE_FLOAT_FROM_DOUBLE(b);
1390 PyObject *r = _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1_float, operand2_float);
1392 Py_DECREF(operand1_float);
1393 Py_DECREF(operand2_float);
1396 goto exit_result_object;
1405 ix = (
unsigned long)ix * temp;
1409 if (ix / temp != prev) {
1410 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1411 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1413 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1415 Py_DECREF(operand1_long);
1416 Py_DECREF(operand2_long);
1419 goto exit_result_object;
1427 temp = (
unsigned long)temp * temp;
1429 if (prev != 0 && temp / prev != prev) {
1430 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1431 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1433 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1435 Py_DECREF(operand1_long);
1436 Py_DECREF(operand2_long);
1439 goto exit_result_object;
1444 goto exit_result_ok_clong;
1447exit_result_ok_clong:
1450 Py_DECREF(*operand1);
1454 *operand1 = Nuitka_PyInt_FromLong(clong_result);
1455 goto exit_result_ok;
1458 if (unlikely(obj_result == NULL)) {
1459 goto exit_result_exception;
1462 Py_DECREF(*operand1);
1464 *operand1 = obj_result;
1465 goto exit_result_ok;
1470exit_result_exception:
1474bool INPLACE_OPERATION_POW_INT_INT(PyObject **operand1, PyObject *operand2) {
1475 return _INPLACE_OPERATION_POW_INT_INT(operand1, operand2);
1479#if PYTHON_VERSION < 0x300
1481static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_POW_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
1482 PyTypeObject *type1 = Py_TYPE(*operand1);
1484#if defined(_MSC_VER)
1485#pragma warning(push)
1486#pragma warning(disable : 4101)
1488 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1489 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1490#if defined(_MSC_VER)
1495 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_power : NULL;
1497 if (islot != NULL) {
1498 PyObject *x = islot(*operand1, operand2, Py_None);
1500 if (x != Py_NotImplemented) {
1502 goto exit_inplace_result_object;
1505 Py_DECREF_IMMORTAL(x);
1510 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_power : NULL;
1511 ternaryfunc slot2 = NULL;
1513 if (!(type1 == &PyInt_Type)) {
1516 slot2 = PyInt_Type.tp_as_number->nb_power;
1518 if (slot1 == slot2) {
1523 if (slot1 != NULL) {
1524 PyObject *x = slot1(*operand1, operand2, Py_None);
1526 if (x != Py_NotImplemented) {
1528 goto exit_inplace_result_object;
1531 Py_DECREF_IMMORTAL(x);
1534 if (slot2 != NULL) {
1535 PyObject *x = slot2(*operand1, operand2, Py_None);
1537 if (x != Py_NotImplemented) {
1539 goto exit_inplace_result_object;
1542 Py_DECREF_IMMORTAL(x);
1545#if PYTHON_VERSION < 0x300
1546 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
1548 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1551 PyObject *coerced1 = *operand1;
1552 PyObject *coerced2 = operand2;
1554 int err = c1(&coerced1, &coerced2);
1556 if (unlikely(err < 0)) {
1557 goto exit_inplace_exception;
1561 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1563 if (likely(mv == NULL)) {
1564 ternaryfunc slot = mv->nb_power;
1566 if (likely(slot != NULL)) {
1567 PyObject *x = slot(coerced1, coerced2, Py_None);
1569 Py_DECREF(coerced1);
1570 Py_DECREF(coerced2);
1573 goto exit_inplace_result_object;
1578 Py_DECREF(coerced1);
1579 Py_DECREF(coerced2);
1582 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
1585 PyObject *coerced1 = *operand1;
1586 PyObject *coerced2 = operand2;
1588 int err = c2(&coerced2, &coerced1);
1590 if (unlikely(err < 0)) {
1591 goto exit_inplace_exception;
1595 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1597 if (likely(mv == NULL)) {
1598 ternaryfunc slot = mv->nb_power;
1600 if (likely(slot != NULL)) {
1601 PyObject *x = slot(coerced1, coerced2, Py_None);
1603 Py_DECREF(coerced1);
1604 Py_DECREF(coerced2);
1607 goto exit_inplace_result_object;
1612 Py_DECREF(coerced1);
1613 Py_DECREF(coerced2);
1619 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: '%s' and 'int'", type1->tp_name);
1620 goto exit_inplace_exception;
1623exit_inplace_result_object:
1624 if (unlikely(obj_result == NULL)) {
1629 Py_DECREF(*operand1);
1633 *operand1 = obj_result;
1637exit_inplace_exception:
1640static inline bool _INPLACE_OPERATION_POW_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
1643 CHECK_OBJECT(*operand1);
1644 CHECK_OBJECT(operand2);
1645 assert(PyInt_CheckExact(operand2));
1647 PyTypeObject *type1 = Py_TYPE(*operand1);
1649 if (type1 == &PyInt_Type) {
1653#if defined(_MSC_VER)
1654#pragma warning(push)
1655#pragma warning(disable : 4101)
1657 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1658 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1659 NUITKA_MAY_BE_UNUSED
long clong_result;
1660 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1661#if defined(_MSC_VER)
1665 CHECK_OBJECT(*operand1);
1666 assert(PyInt_CheckExact(*operand1));
1667 CHECK_OBJECT(operand2);
1668 assert(PyInt_CheckExact(operand2));
1670 const long a = PyInt_AS_LONG(*operand1);
1671 const long b = PyInt_AS_LONG(operand2);
1675 PyObject *operand1_float = MAKE_FLOAT_FROM_DOUBLE(a);
1676 PyObject *operand2_float = MAKE_FLOAT_FROM_DOUBLE(b);
1678 PyObject *r = _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1_float, operand2_float);
1680 Py_DECREF(operand1_float);
1681 Py_DECREF(operand2_float);
1684 goto exit_result_object;
1693 ix = (
unsigned long)ix * temp;
1697 if (ix / temp != prev) {
1698 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1699 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1701 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1703 Py_DECREF(operand1_long);
1704 Py_DECREF(operand2_long);
1707 goto exit_result_object;
1715 temp = (
unsigned long)temp * temp;
1717 if (prev != 0 && temp / prev != prev) {
1718 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1719 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1721 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1723 Py_DECREF(operand1_long);
1724 Py_DECREF(operand2_long);
1727 goto exit_result_object;
1732 goto exit_result_ok_clong;
1735 exit_result_ok_clong:
1738 Py_DECREF(*operand1);
1742 *operand1 = Nuitka_PyInt_FromLong(clong_result);
1743 goto exit_result_ok;
1746 if (unlikely(obj_result == NULL)) {
1747 goto exit_result_exception;
1750 Py_DECREF(*operand1);
1752 *operand1 = obj_result;
1753 goto exit_result_ok;
1758 exit_result_exception:
1762 return __INPLACE_OPERATION_POW_OBJECT_INT(operand1, operand2);
1765bool INPLACE_OPERATION_POW_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
1766 return _INPLACE_OPERATION_POW_OBJECT_INT(operand1, operand2);
1770#if PYTHON_VERSION < 0x300
1772static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_POW_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
1773 PyTypeObject *type2 = Py_TYPE(operand2);
1775#if defined(_MSC_VER)
1776#pragma warning(push)
1777#pragma warning(disable : 4101)
1779 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1780 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1781#if defined(_MSC_VER)
1788 ternaryfunc slot1 = PyInt_Type.tp_as_number->nb_power;
1789 ternaryfunc slot2 = NULL;
1791 if (!(&PyInt_Type == type2)) {
1795 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_power : NULL;
1797 if (slot1 == slot2) {
1802 if (slot1 != NULL) {
1803 if (slot2 != NULL) {
1804 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
1805 PyObject *x = slot2(*operand1, operand2, Py_None);
1807 if (x != Py_NotImplemented) {
1809 goto exit_inplace_result_object;
1812 Py_DECREF_IMMORTAL(x);
1817 PyObject *x = slot1(*operand1, operand2, Py_None);
1819 if (x != Py_NotImplemented) {
1821 goto exit_inplace_result_object;
1824 Py_DECREF_IMMORTAL(x);
1827 if (slot2 != NULL) {
1828 PyObject *x = slot2(*operand1, operand2, Py_None);
1830 if (x != Py_NotImplemented) {
1832 goto exit_inplace_result_object;
1835 Py_DECREF_IMMORTAL(x);
1838#if PYTHON_VERSION < 0x300
1839 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1840 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
1843 PyObject *coerced1 = *operand1;
1844 PyObject *coerced2 = operand2;
1846 int err = c1(&coerced1, &coerced2);
1848 if (unlikely(err < 0)) {
1849 goto exit_inplace_exception;
1853 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1855 if (likely(mv == NULL)) {
1856 ternaryfunc slot = mv->nb_power;
1858 if (likely(slot != NULL)) {
1859 PyObject *x = slot(coerced1, coerced2, Py_None);
1861 Py_DECREF(coerced1);
1862 Py_DECREF(coerced2);
1865 goto exit_inplace_result_object;
1870 Py_DECREF(coerced1);
1871 Py_DECREF(coerced2);
1875 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1878 PyObject *coerced1 = *operand1;
1879 PyObject *coerced2 = operand2;
1881 int err = c2(&coerced2, &coerced1);
1883 if (unlikely(err < 0)) {
1884 goto exit_inplace_exception;
1888 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1890 if (likely(mv == NULL)) {
1891 ternaryfunc slot = mv->nb_power;
1893 if (likely(slot != NULL)) {
1894 PyObject *x = slot(coerced1, coerced2, Py_None);
1896 Py_DECREF(coerced1);
1897 Py_DECREF(coerced2);
1900 goto exit_inplace_result_object;
1905 Py_DECREF(coerced1);
1906 Py_DECREF(coerced2);
1912 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'int' and '%s'", type2->tp_name);
1913 goto exit_inplace_exception;
1916exit_inplace_result_object:
1917 if (unlikely(obj_result == NULL)) {
1922 Py_DECREF(*operand1);
1926 *operand1 = obj_result;
1930exit_inplace_exception:
1933static inline bool _INPLACE_OPERATION_POW_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
1936 CHECK_OBJECT(*operand1);
1937 assert(PyInt_CheckExact(*operand1));
1938 CHECK_OBJECT(operand2);
1940 PyTypeObject *type2 = Py_TYPE(operand2);
1942 if (&PyInt_Type == type2) {
1946#if defined(_MSC_VER)
1947#pragma warning(push)
1948#pragma warning(disable : 4101)
1950 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1951 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1952 NUITKA_MAY_BE_UNUSED
long clong_result;
1953 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1954#if defined(_MSC_VER)
1958 CHECK_OBJECT(*operand1);
1959 assert(PyInt_CheckExact(*operand1));
1960 CHECK_OBJECT(operand2);
1961 assert(PyInt_CheckExact(operand2));
1963 const long a = PyInt_AS_LONG(*operand1);
1964 const long b = PyInt_AS_LONG(operand2);
1968 PyObject *operand1_float = MAKE_FLOAT_FROM_DOUBLE(a);
1969 PyObject *operand2_float = MAKE_FLOAT_FROM_DOUBLE(b);
1971 PyObject *r = _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1_float, operand2_float);
1973 Py_DECREF(operand1_float);
1974 Py_DECREF(operand2_float);
1977 goto exit_result_object;
1986 ix = (
unsigned long)ix * temp;
1990 if (ix / temp != prev) {
1991 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1992 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1994 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
1996 Py_DECREF(operand1_long);
1997 Py_DECREF(operand2_long);
2000 goto exit_result_object;
2008 temp = (
unsigned long)temp * temp;
2010 if (prev != 0 && temp / prev != prev) {
2011 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
2012 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
2014 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
2016 Py_DECREF(operand1_long);
2017 Py_DECREF(operand2_long);
2020 goto exit_result_object;
2025 goto exit_result_ok_clong;
2028 exit_result_ok_clong:
2031 Py_DECREF(*operand1);
2035 *operand1 = Nuitka_PyInt_FromLong(clong_result);
2036 goto exit_result_ok;
2039 if (unlikely(obj_result == NULL)) {
2040 goto exit_result_exception;
2043 Py_DECREF(*operand1);
2045 *operand1 = obj_result;
2046 goto exit_result_ok;
2051 exit_result_exception:
2055 return __INPLACE_OPERATION_POW_INT_OBJECT(operand1, operand2);
2058bool INPLACE_OPERATION_POW_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
2059 return _INPLACE_OPERATION_POW_INT_OBJECT(operand1, operand2);
2064static inline bool _INPLACE_OPERATION_POW_FLOAT_LONG(PyObject **operand1, PyObject *operand2) {
2067 CHECK_OBJECT(*operand1);
2068 assert(PyFloat_CheckExact(*operand1));
2069 CHECK_OBJECT(operand2);
2070 assert(PyLong_CheckExact(operand2));
2072#if defined(_MSC_VER)
2073#pragma warning(push)
2074#pragma warning(disable : 4101)
2076 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2077 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2078#if defined(_MSC_VER)
2085 ternaryfunc slot1 = PyFloat_Type.tp_as_number->nb_power;
2088 if (slot1 != NULL) {
2089 PyObject *x = slot1(*operand1, operand2, Py_None);
2091 if (x != Py_NotImplemented) {
2093 goto exit_inplace_result_object;
2096 Py_DECREF_IMMORTAL(x);
2101#if PYTHON_VERSION < 0x300
2102 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'float' and 'long'");
2104 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'float' and 'int'");
2106 goto exit_inplace_exception;
2109exit_inplace_result_object:
2110 if (unlikely(obj_result == NULL)) {
2115 Py_DECREF(*operand1);
2119 *operand1 = obj_result;
2123exit_inplace_exception:
2127bool INPLACE_OPERATION_POW_FLOAT_LONG(PyObject **operand1, PyObject *operand2) {
2128 return _INPLACE_OPERATION_POW_FLOAT_LONG(operand1, operand2);
2132static inline bool _INPLACE_OPERATION_POW_LONG_FLOAT(PyObject **operand1, PyObject *operand2) {
2135 CHECK_OBJECT(*operand1);
2136 assert(PyLong_CheckExact(*operand1));
2137 CHECK_OBJECT(operand2);
2138 assert(PyFloat_CheckExact(operand2));
2140#if defined(_MSC_VER)
2141#pragma warning(push)
2142#pragma warning(disable : 4101)
2144 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2145 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2146#if defined(_MSC_VER)
2154 ternaryfunc slot2 = NULL;
2159 slot2 = PyFloat_Type.tp_as_number->nb_power;
2162 if (slot2 != NULL) {
2163 PyObject *x = slot2(*operand1, operand2, Py_None);
2165 if (x != Py_NotImplemented) {
2167 goto exit_inplace_result_object;
2170 Py_DECREF_IMMORTAL(x);
2175#if PYTHON_VERSION < 0x300
2176 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'long' and 'float'");
2178 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'int' and 'float'");
2180 goto exit_inplace_exception;
2183exit_inplace_result_object:
2184 if (unlikely(obj_result == NULL)) {
2189 Py_DECREF(*operand1);
2193 *operand1 = obj_result;
2197exit_inplace_exception:
2201bool INPLACE_OPERATION_POW_LONG_FLOAT(PyObject **operand1, PyObject *operand2) {
2202 return _INPLACE_OPERATION_POW_LONG_FLOAT(operand1, operand2);
2205#if PYTHON_VERSION < 0x300
2207static inline bool _INPLACE_OPERATION_POW_FLOAT_INT(PyObject **operand1, PyObject *operand2) {
2210 CHECK_OBJECT(*operand1);
2211 assert(PyFloat_CheckExact(*operand1));
2212 CHECK_OBJECT(operand2);
2213 assert(PyInt_CheckExact(operand2));
2215#if defined(_MSC_VER)
2216#pragma warning(push)
2217#pragma warning(disable : 4101)
2219 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2220 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2221#if defined(_MSC_VER)
2228 ternaryfunc slot1 = PyFloat_Type.tp_as_number->nb_power;
2231 if (slot1 != NULL) {
2232 PyObject *x = slot1(*operand1, operand2, Py_None);
2234 if (x != Py_NotImplemented) {
2236 goto exit_inplace_result_object;
2239 Py_DECREF_IMMORTAL(x);
2244 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'float' and 'int'");
2245 goto exit_inplace_exception;
2248exit_inplace_result_object:
2249 if (unlikely(obj_result == NULL)) {
2254 Py_DECREF(*operand1);
2258 *operand1 = obj_result;
2262exit_inplace_exception:
2266bool INPLACE_OPERATION_POW_FLOAT_INT(PyObject **operand1, PyObject *operand2) {
2267 return _INPLACE_OPERATION_POW_FLOAT_INT(operand1, operand2);
2271#if PYTHON_VERSION < 0x300
2273static inline bool _INPLACE_OPERATION_POW_INT_FLOAT(PyObject **operand1, PyObject *operand2) {
2276 CHECK_OBJECT(*operand1);
2277 assert(PyInt_CheckExact(*operand1));
2278 CHECK_OBJECT(operand2);
2279 assert(PyFloat_CheckExact(operand2));
2281#if defined(_MSC_VER)
2282#pragma warning(push)
2283#pragma warning(disable : 4101)
2285 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2286 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2287#if defined(_MSC_VER)
2295 ternaryfunc slot2 = NULL;
2300 slot2 = PyFloat_Type.tp_as_number->nb_power;
2303 if (slot2 != NULL) {
2304 PyObject *x = slot2(*operand1, operand2, Py_None);
2306 if (x != Py_NotImplemented) {
2308 goto exit_inplace_result_object;
2311 Py_DECREF_IMMORTAL(x);
2316 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'int' and 'float'");
2317 goto exit_inplace_exception;
2320exit_inplace_result_object:
2321 if (unlikely(obj_result == NULL)) {
2326 Py_DECREF(*operand1);
2330 *operand1 = obj_result;
2334exit_inplace_exception:
2338bool INPLACE_OPERATION_POW_INT_FLOAT(PyObject **operand1, PyObject *operand2) {
2339 return _INPLACE_OPERATION_POW_INT_FLOAT(operand1, operand2);
2343#if PYTHON_VERSION < 0x300
2345static inline bool _INPLACE_OPERATION_POW_LONG_INT(PyObject **operand1, PyObject *operand2) {
2348 CHECK_OBJECT(*operand1);
2349 assert(PyLong_CheckExact(*operand1));
2350 CHECK_OBJECT(operand2);
2351 assert(PyInt_CheckExact(operand2));
2353#if defined(_MSC_VER)
2354#pragma warning(push)
2355#pragma warning(disable : 4101)
2357 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2358 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2359#if defined(_MSC_VER)
2366 ternaryfunc slot1 = PyLong_Type.tp_as_number->nb_power;
2369 if (slot1 != NULL) {
2370 PyObject *x = slot1(*operand1, operand2, Py_None);
2372 if (x != Py_NotImplemented) {
2374 goto exit_inplace_result_object;
2377 Py_DECREF_IMMORTAL(x);
2382 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'long' and 'int'");
2383 goto exit_inplace_exception;
2386exit_inplace_result_object:
2387 if (unlikely(obj_result == NULL)) {
2392 Py_DECREF(*operand1);
2396 *operand1 = obj_result;
2400exit_inplace_exception:
2404bool INPLACE_OPERATION_POW_LONG_INT(PyObject **operand1, PyObject *operand2) {
2405 return _INPLACE_OPERATION_POW_LONG_INT(operand1, operand2);
2409#if PYTHON_VERSION < 0x300
2411static inline bool _INPLACE_OPERATION_POW_INT_LONG(PyObject **operand1, PyObject *operand2) {
2414 CHECK_OBJECT(*operand1);
2415 assert(PyInt_CheckExact(*operand1));
2416 CHECK_OBJECT(operand2);
2417 assert(PyLong_CheckExact(operand2));
2419#if defined(_MSC_VER)
2420#pragma warning(push)
2421#pragma warning(disable : 4101)
2423 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2424 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2425#if defined(_MSC_VER)
2433 ternaryfunc slot2 = NULL;
2438 slot2 = PyLong_Type.tp_as_number->nb_power;
2441 if (slot2 != NULL) {
2442 PyObject *x = slot2(*operand1, operand2, Py_None);
2444 if (x != Py_NotImplemented) {
2446 goto exit_inplace_result_object;
2449 Py_DECREF_IMMORTAL(x);
2454 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: 'int' and 'long'");
2455 goto exit_inplace_exception;
2458exit_inplace_result_object:
2459 if (unlikely(obj_result == NULL)) {
2464 Py_DECREF(*operand1);
2468 *operand1 = obj_result;
2472exit_inplace_exception:
2476bool INPLACE_OPERATION_POW_INT_LONG(PyObject **operand1, PyObject *operand2) {
2477 return _INPLACE_OPERATION_POW_INT_LONG(operand1, operand2);
2482static inline bool _INPLACE_OPERATION_POW_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
2485 CHECK_OBJECT(*operand1);
2486 CHECK_OBJECT(operand2);
2488#if PYTHON_VERSION < 0x300
2489 if (PyInt_CheckExact(*operand1) && PyInt_CheckExact(operand2)) {
2492#if defined(_MSC_VER)
2493#pragma warning(push)
2494#pragma warning(disable : 4101)
2496 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2497 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2498 NUITKA_MAY_BE_UNUSED
long clong_result;
2499 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2500#if defined(_MSC_VER)
2504 CHECK_OBJECT(*operand1);
2505 assert(PyInt_CheckExact(*operand1));
2506 CHECK_OBJECT(operand2);
2507 assert(PyInt_CheckExact(operand2));
2509 const long a = PyInt_AS_LONG(*operand1);
2510 const long b = PyInt_AS_LONG(operand2);
2514 PyObject *operand1_float = MAKE_FLOAT_FROM_DOUBLE(a);
2515 PyObject *operand2_float = MAKE_FLOAT_FROM_DOUBLE(b);
2517 PyObject *r = _BINARY_OPERATION_POW_OBJECT_FLOAT_FLOAT(operand1_float, operand2_float);
2519 Py_DECREF(operand1_float);
2520 Py_DECREF(operand2_float);
2523 goto exit_result_object;
2532 ix = (
unsigned long)ix * temp;
2536 if (ix / temp != prev) {
2537 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
2538 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
2540 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
2542 Py_DECREF(operand1_long);
2543 Py_DECREF(operand2_long);
2546 goto exit_result_object;
2554 temp = (
unsigned long)temp * temp;
2556 if (prev != 0 && temp / prev != prev) {
2557 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
2558 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
2560 PyObject *r = _BINARY_OPERATION_POW_OBJECT_LONG_LONG(operand1_long, operand2_long);
2562 Py_DECREF(operand1_long);
2563 Py_DECREF(operand2_long);
2566 goto exit_result_object;
2571 goto exit_result_ok_clong;
2574 exit_result_ok_clong:
2577 Py_DECREF(*operand1);
2581 *operand1 = Nuitka_PyInt_FromLong(clong_result);
2582 goto exit_result_ok;
2585 if (unlikely(obj_result == NULL)) {
2586 goto exit_result_exception;
2589 Py_DECREF(*operand1);
2591 *operand1 = obj_result;
2592 goto exit_result_ok;
2597 exit_result_exception:
2602 if (Py_TYPE(*operand1) == Py_TYPE(operand2)) {
2603 if (PyFloat_CheckExact(operand2)) {
2604 return _INPLACE_OPERATION_POW_FLOAT_FLOAT(operand1, operand2);
2606#if PYTHON_VERSION >= 0x300
2607 if (PyLong_CheckExact(operand2)) {
2608 return _INPLACE_OPERATION_POW_LONG_LONG(operand1, operand2);
2613 PyTypeObject *type1 = Py_TYPE(*operand1);
2614 PyTypeObject *type2 = Py_TYPE(operand2);
2616#if defined(_MSC_VER)
2617#pragma warning(push)
2618#pragma warning(disable : 4101)
2620 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2621 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2622#if defined(_MSC_VER)
2627 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_power : NULL;
2629 if (islot != NULL) {
2630 PyObject *x = islot(*operand1, operand2, Py_None);
2632 if (x != Py_NotImplemented) {
2634 goto exit_inplace_result_object;
2637 Py_DECREF_IMMORTAL(x);
2642 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_power : NULL;
2643 ternaryfunc slot2 = NULL;
2645 if (!(type1 == type2)) {
2649 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_power : NULL;
2651 if (slot1 == slot2) {
2656 if (slot1 != NULL) {
2657 if (slot2 != NULL) {
2658 if (Nuitka_Type_IsSubtype(type2, type1)) {
2659 PyObject *x = slot2(*operand1, operand2, Py_None);
2661 if (x != Py_NotImplemented) {
2663 goto exit_inplace_result_object;
2666 Py_DECREF_IMMORTAL(x);
2671 PyObject *x = slot1(*operand1, operand2, Py_None);
2673 if (x != Py_NotImplemented) {
2675 goto exit_inplace_result_object;
2678 Py_DECREF_IMMORTAL(x);
2681 if (slot2 != NULL) {
2682 PyObject *x = slot2(*operand1, operand2, Py_None);
2684 if (x != Py_NotImplemented) {
2686 goto exit_inplace_result_object;
2689 Py_DECREF_IMMORTAL(x);
2692#if PYTHON_VERSION < 0x300
2693 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
2695 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
2698 PyObject *coerced1 = *operand1;
2699 PyObject *coerced2 = operand2;
2701 int err = c1(&coerced1, &coerced2);
2703 if (unlikely(err < 0)) {
2704 goto exit_inplace_exception;
2708 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2710 if (likely(mv == NULL)) {
2711 ternaryfunc slot = mv->nb_power;
2713 if (likely(slot != NULL)) {
2714 PyObject *x = slot(coerced1, coerced2, Py_None);
2716 Py_DECREF(coerced1);
2717 Py_DECREF(coerced2);
2720 goto exit_inplace_result_object;
2725 Py_DECREF(coerced1);
2726 Py_DECREF(coerced2);
2730 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
2733 PyObject *coerced1 = *operand1;
2734 PyObject *coerced2 = operand2;
2736 int err = c2(&coerced2, &coerced1);
2738 if (unlikely(err < 0)) {
2739 goto exit_inplace_exception;
2743 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2745 if (likely(mv == NULL)) {
2746 ternaryfunc slot = mv->nb_power;
2748 if (likely(slot != NULL)) {
2749 PyObject *x = slot(coerced1, coerced2, Py_None);
2751 Py_DECREF(coerced1);
2752 Py_DECREF(coerced2);
2755 goto exit_inplace_result_object;
2760 Py_DECREF(coerced1);
2761 Py_DECREF(coerced2);
2767 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for **=: '%s' and '%s'", type1->tp_name,
2769 goto exit_inplace_exception;
2772exit_inplace_result_object:
2773 if (unlikely(obj_result == NULL)) {
2778 Py_DECREF(*operand1);
2782 *operand1 = obj_result;
2786exit_inplace_exception:
2790bool INPLACE_OPERATION_POW_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
2791 return _INPLACE_OPERATION_POW_OBJECT_OBJECT(operand1, operand2);