7#include "nuitka/prelude.h"
12#if PYTHON_VERSION < 0x300
14static inline bool _INPLACE_OPERATION_SUB_INT_INT(PyObject **operand1, PyObject *operand2) {
17 CHECK_OBJECT(*operand1);
18 assert(PyInt_CheckExact(*operand1));
19 CHECK_OBJECT(operand2);
20 assert(PyInt_CheckExact(operand2));
25#pragma warning(disable : 4101)
27 NUITKA_MAY_BE_UNUSED
bool cbool_result;
28 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
29 NUITKA_MAY_BE_UNUSED
long clong_result;
30 NUITKA_MAY_BE_UNUSED
double cfloat_result;
35 CHECK_OBJECT(*operand1);
36 assert(PyInt_CheckExact(*operand1));
37 CHECK_OBJECT(operand2);
38 assert(PyInt_CheckExact(operand2));
40 const long a = PyInt_AS_LONG(*operand1);
41 const long b = PyInt_AS_LONG(operand2);
43 const long x = (long)((
unsigned long)a - b);
44 bool no_overflow = ((x ^ a) >= 0 || (x ^ ~b) >= 0);
45 if (likely(no_overflow)) {
47 goto exit_result_ok_clong;
51 PyObject *operand1_object = *operand1;
52 PyObject *operand2_object = operand2;
54 PyObject *r = PyLong_Type.tp_as_number->nb_subtract(operand1_object, operand2_object);
55 assert(r != Py_NotImplemented);
58 goto exit_result_object;
68 *operand1 = Nuitka_PyInt_FromLong(clong_result);
72 if (unlikely(obj_result == NULL)) {
73 goto exit_result_exception;
78 *operand1 = obj_result;
88bool INPLACE_OPERATION_SUB_INT_INT(PyObject **operand1, PyObject *operand2) {
89 return _INPLACE_OPERATION_SUB_INT_INT(operand1, operand2);
93#if PYTHON_VERSION < 0x300
95static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_SUB_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
96 PyTypeObject *type1 = Py_TYPE(*operand1);
100#pragma warning(disable : 4101)
102 NUITKA_MAY_BE_UNUSED
bool cbool_result;
103 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
109 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_subtract : NULL;
112 PyObject *x = islot(*operand1, operand2);
114 if (x != Py_NotImplemented) {
116 goto exit_inplace_result_object;
119 Py_DECREF_IMMORTAL(x);
124 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_subtract : NULL;
125 binaryfunc slot2 = NULL;
127 if (!(type1 == &PyInt_Type)) {
130 slot2 = PyInt_Type.tp_as_number->nb_subtract;
132 if (slot1 == slot2) {
138 PyObject *x = slot1(*operand1, operand2);
140 if (x != Py_NotImplemented) {
142 goto exit_inplace_result_object;
145 Py_DECREF_IMMORTAL(x);
149 PyObject *x = slot2(*operand1, operand2);
151 if (x != Py_NotImplemented) {
153 goto exit_inplace_result_object;
156 Py_DECREF_IMMORTAL(x);
159#if PYTHON_VERSION < 0x300
160 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
162 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
165 PyObject *coerced1 = *operand1;
166 PyObject *coerced2 = operand2;
168 int err = c1(&coerced1, &coerced2);
170 if (unlikely(err < 0)) {
171 goto exit_inplace_exception;
175 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
177 if (likely(mv == NULL)) {
178 binaryfunc slot = mv->nb_subtract;
180 if (likely(slot != NULL)) {
181 PyObject *x = slot(coerced1, coerced2);
187 goto exit_inplace_result_object;
196 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
199 PyObject *coerced1 = *operand1;
200 PyObject *coerced2 = operand2;
202 int err = c2(&coerced2, &coerced1);
204 if (unlikely(err < 0)) {
205 goto exit_inplace_exception;
209 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
211 if (likely(mv == NULL)) {
212 binaryfunc slot = mv->nb_subtract;
214 if (likely(slot != NULL)) {
215 PyObject *x = slot(coerced1, coerced2);
221 goto exit_inplace_result_object;
233 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: '%s' and 'int'", type1->tp_name);
234 goto exit_inplace_exception;
237exit_inplace_result_object:
238 if (unlikely(obj_result == NULL)) {
243 Py_DECREF(*operand1);
247 *operand1 = obj_result;
251exit_inplace_exception:
254static inline bool _INPLACE_OPERATION_SUB_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
257 CHECK_OBJECT(*operand1);
258 CHECK_OBJECT(operand2);
259 assert(PyInt_CheckExact(operand2));
261 PyTypeObject *type1 = Py_TYPE(*operand1);
263 if (type1 == &PyInt_Type) {
269#pragma warning(disable : 4101)
271 NUITKA_MAY_BE_UNUSED
bool cbool_result;
272 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
273 NUITKA_MAY_BE_UNUSED
long clong_result;
274 NUITKA_MAY_BE_UNUSED
double cfloat_result;
279 CHECK_OBJECT(*operand1);
280 assert(PyInt_CheckExact(*operand1));
281 CHECK_OBJECT(operand2);
282 assert(PyInt_CheckExact(operand2));
284 const long a = PyInt_AS_LONG(*operand1);
285 const long b = PyInt_AS_LONG(operand2);
287 const long x = (long)((
unsigned long)a - b);
288 bool no_overflow = ((x ^ a) >= 0 || (x ^ ~b) >= 0);
289 if (likely(no_overflow)) {
291 goto exit_result_ok_clong;
295 PyObject *operand1_object = *operand1;
296 PyObject *operand2_object = operand2;
298 PyObject *r = PyLong_Type.tp_as_number->nb_subtract(operand1_object, operand2_object);
299 assert(r != Py_NotImplemented);
302 goto exit_result_object;
305 exit_result_ok_clong:
308 Py_DECREF(*operand1);
312 *operand1 = Nuitka_PyInt_FromLong(clong_result);
316 if (unlikely(obj_result == NULL)) {
317 goto exit_result_exception;
320 Py_DECREF(*operand1);
322 *operand1 = obj_result;
328 exit_result_exception:
332 return __INPLACE_OPERATION_SUB_OBJECT_INT(operand1, operand2);
335bool INPLACE_OPERATION_SUB_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
336 return _INPLACE_OPERATION_SUB_OBJECT_INT(operand1, operand2);
340#if PYTHON_VERSION < 0x300
342static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_SUB_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
343 PyTypeObject *type2 = Py_TYPE(operand2);
347#pragma warning(disable : 4101)
349 NUITKA_MAY_BE_UNUSED
bool cbool_result;
350 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
358 binaryfunc slot1 = PyInt_Type.tp_as_number->nb_subtract;
359 binaryfunc slot2 = NULL;
361 if (!(&PyInt_Type == type2)) {
365 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_subtract : NULL;
367 if (slot1 == slot2) {
374 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
375 PyObject *x = slot2(*operand1, operand2);
377 if (x != Py_NotImplemented) {
379 goto exit_inplace_result_object;
382 Py_DECREF_IMMORTAL(x);
387 PyObject *x = slot1(*operand1, operand2);
389 if (x != Py_NotImplemented) {
391 goto exit_inplace_result_object;
394 Py_DECREF_IMMORTAL(x);
398 PyObject *x = slot2(*operand1, operand2);
400 if (x != Py_NotImplemented) {
402 goto exit_inplace_result_object;
405 Py_DECREF_IMMORTAL(x);
408#if PYTHON_VERSION < 0x300
409 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
410 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
413 PyObject *coerced1 = *operand1;
414 PyObject *coerced2 = operand2;
416 int err = c1(&coerced1, &coerced2);
418 if (unlikely(err < 0)) {
419 goto exit_inplace_exception;
423 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
425 if (likely(mv == NULL)) {
426 binaryfunc slot = mv->nb_subtract;
428 if (likely(slot != NULL)) {
429 PyObject *x = slot(coerced1, coerced2);
435 goto exit_inplace_result_object;
445 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
448 PyObject *coerced1 = *operand1;
449 PyObject *coerced2 = operand2;
451 int err = c2(&coerced2, &coerced1);
453 if (unlikely(err < 0)) {
454 goto exit_inplace_exception;
458 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
460 if (likely(mv == NULL)) {
461 binaryfunc slot = mv->nb_subtract;
463 if (likely(slot != NULL)) {
464 PyObject *x = slot(coerced1, coerced2);
470 goto exit_inplace_result_object;
482 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'int' and '%s'", type2->tp_name);
483 goto exit_inplace_exception;
486exit_inplace_result_object:
487 if (unlikely(obj_result == NULL)) {
492 Py_DECREF(*operand1);
496 *operand1 = obj_result;
500exit_inplace_exception:
503static inline bool _INPLACE_OPERATION_SUB_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
506 CHECK_OBJECT(*operand1);
507 assert(PyInt_CheckExact(*operand1));
508 CHECK_OBJECT(operand2);
510 PyTypeObject *type2 = Py_TYPE(operand2);
512 if (&PyInt_Type == type2) {
518#pragma warning(disable : 4101)
520 NUITKA_MAY_BE_UNUSED
bool cbool_result;
521 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
522 NUITKA_MAY_BE_UNUSED
long clong_result;
523 NUITKA_MAY_BE_UNUSED
double cfloat_result;
528 CHECK_OBJECT(*operand1);
529 assert(PyInt_CheckExact(*operand1));
530 CHECK_OBJECT(operand2);
531 assert(PyInt_CheckExact(operand2));
533 const long a = PyInt_AS_LONG(*operand1);
534 const long b = PyInt_AS_LONG(operand2);
536 const long x = (long)((
unsigned long)a - b);
537 bool no_overflow = ((x ^ a) >= 0 || (x ^ ~b) >= 0);
538 if (likely(no_overflow)) {
540 goto exit_result_ok_clong;
544 PyObject *operand1_object = *operand1;
545 PyObject *operand2_object = operand2;
547 PyObject *r = PyLong_Type.tp_as_number->nb_subtract(operand1_object, operand2_object);
548 assert(r != Py_NotImplemented);
551 goto exit_result_object;
554 exit_result_ok_clong:
557 Py_DECREF(*operand1);
561 *operand1 = Nuitka_PyInt_FromLong(clong_result);
565 if (unlikely(obj_result == NULL)) {
566 goto exit_result_exception;
569 Py_DECREF(*operand1);
571 *operand1 = obj_result;
577 exit_result_exception:
581 return __INPLACE_OPERATION_SUB_INT_OBJECT(operand1, operand2);
584bool INPLACE_OPERATION_SUB_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
585 return _INPLACE_OPERATION_SUB_INT_OBJECT(operand1, operand2);
590static inline bool _INPLACE_OPERATION_SUB_LONG_LONG(PyObject **operand1, PyObject *operand2) {
593 CHECK_OBJECT(*operand1);
594 assert(PyLong_CheckExact(*operand1));
595 CHECK_OBJECT(operand2);
596 assert(PyLong_CheckExact(operand2));
601#pragma warning(disable : 4101)
603 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
604 NUITKA_MAY_BE_UNUSED
long clong_result;
609 PyLongObject *operand1_long_object = (PyLongObject *)*operand1;
611 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
613 if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && Nuitka_LongGetDigitSize(operand2_long_object) <= 1) {
614 long r = (long)(MEDIUM_VALUE(operand1_long_object) - MEDIUM_VALUE(operand2_long_object));
616 if (Py_REFCNT(*operand1) == 1) {
617 Nuitka_LongUpdateFromCLong(&*operand1, r);
620 PyObject *obj = Nuitka_LongFromCLong(r);
623 goto exit_result_object;
626 goto exit_result_ok_clong;
629 if (Py_REFCNT(*operand1) == 1) {
630 digit
const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
631 Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
633 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
634 bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
638 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, -1);
640 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
641 Nuitka_LongSetSignNegative(*operand1);
645 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
647 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, 1);
656 digit
const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
657 Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
658 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
659 digit
const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
660 Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
661 bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
665 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
667 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
670 Nuitka_LongFlipSign(z);
673 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
675 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
679 obj_result = (PyObject *)z;
680 goto exit_result_object;
684 if (unlikely(obj_result == NULL)) {
685 goto exit_result_exception;
688 Py_DECREF(*operand1);
689 *operand1 = obj_result;
695 Py_DECREF(*operand1);
699 *operand1 = Nuitka_PyLong_FromLong(clong_result);
705exit_result_exception:
709bool INPLACE_OPERATION_SUB_LONG_LONG(PyObject **operand1, PyObject *operand2) {
710 return _INPLACE_OPERATION_SUB_LONG_LONG(operand1, operand2);
714static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_SUB_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
715 PyTypeObject *type1 = Py_TYPE(*operand1);
719#pragma warning(disable : 4101)
721 NUITKA_MAY_BE_UNUSED
bool cbool_result;
722 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
728 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_subtract : NULL;
731 PyObject *x = islot(*operand1, operand2);
733 if (x != Py_NotImplemented) {
735 goto exit_inplace_result_object;
738 Py_DECREF_IMMORTAL(x);
743 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_subtract : NULL;
744 binaryfunc slot2 = NULL;
746 if (!(type1 == &PyLong_Type)) {
749 slot2 = PyLong_Type.tp_as_number->nb_subtract;
751 if (slot1 == slot2) {
757 PyObject *x = slot1(*operand1, operand2);
759 if (x != Py_NotImplemented) {
761 goto exit_inplace_result_object;
764 Py_DECREF_IMMORTAL(x);
768 PyObject *x = slot2(*operand1, operand2);
770 if (x != Py_NotImplemented) {
772 goto exit_inplace_result_object;
775 Py_DECREF_IMMORTAL(x);
778#if PYTHON_VERSION < 0x300
779 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
781 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
784 PyObject *coerced1 = *operand1;
785 PyObject *coerced2 = operand2;
787 int err = c1(&coerced1, &coerced2);
789 if (unlikely(err < 0)) {
790 goto exit_inplace_exception;
794 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
796 if (likely(mv == NULL)) {
797 binaryfunc slot = mv->nb_subtract;
799 if (likely(slot != NULL)) {
800 PyObject *x = slot(coerced1, coerced2);
806 goto exit_inplace_result_object;
815 coercion c2 = PyLong_Type.tp_as_number->nb_coerce;
818 PyObject *coerced1 = *operand1;
819 PyObject *coerced2 = operand2;
821 int err = c2(&coerced2, &coerced1);
823 if (unlikely(err < 0)) {
824 goto exit_inplace_exception;
828 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
830 if (likely(mv == NULL)) {
831 binaryfunc slot = mv->nb_subtract;
833 if (likely(slot != NULL)) {
834 PyObject *x = slot(coerced1, coerced2);
840 goto exit_inplace_result_object;
852#if PYTHON_VERSION < 0x300
853 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: '%s' and 'long'", type1->tp_name);
855 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: '%s' and 'int'", type1->tp_name);
857 goto exit_inplace_exception;
860exit_inplace_result_object:
861 if (unlikely(obj_result == NULL)) {
866 Py_DECREF(*operand1);
870 *operand1 = obj_result;
874exit_inplace_exception:
877static inline bool _INPLACE_OPERATION_SUB_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
880 CHECK_OBJECT(*operand1);
881 CHECK_OBJECT(operand2);
882 assert(PyLong_CheckExact(operand2));
884 PyTypeObject *type1 = Py_TYPE(*operand1);
886 if (type1 == &PyLong_Type) {
892#pragma warning(disable : 4101)
894 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
895 NUITKA_MAY_BE_UNUSED
long clong_result;
900 PyLongObject *operand1_long_object = (PyLongObject *)*operand1;
902 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
904 if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && Nuitka_LongGetDigitSize(operand2_long_object) <= 1) {
905 long r = (long)(MEDIUM_VALUE(operand1_long_object) - MEDIUM_VALUE(operand2_long_object));
907 if (Py_REFCNT(*operand1) == 1) {
908 Nuitka_LongUpdateFromCLong(&*operand1, r);
911 PyObject *obj = Nuitka_LongFromCLong(r);
914 goto exit_result_object;
917 goto exit_result_ok_clong;
920 if (Py_REFCNT(*operand1) == 1) {
921 digit
const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
922 Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
924 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
925 bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
929 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, -1);
931 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
932 Nuitka_LongSetSignNegative(*operand1);
936 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
938 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, 1);
947 digit
const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
948 Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
949 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
950 digit
const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
951 Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
952 bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
956 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
958 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
961 Nuitka_LongFlipSign(z);
964 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
966 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
970 obj_result = (PyObject *)z;
971 goto exit_result_object;
975 if (unlikely(obj_result == NULL)) {
976 goto exit_result_exception;
979 Py_DECREF(*operand1);
980 *operand1 = obj_result;
983 exit_result_ok_clong:
986 Py_DECREF(*operand1);
990 *operand1 = Nuitka_PyLong_FromLong(clong_result);
996 exit_result_exception:
1000 return __INPLACE_OPERATION_SUB_OBJECT_LONG(operand1, operand2);
1003bool INPLACE_OPERATION_SUB_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
1004 return _INPLACE_OPERATION_SUB_OBJECT_LONG(operand1, operand2);
1008static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_SUB_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
1009 PyTypeObject *type2 = Py_TYPE(operand2);
1011#if defined(_MSC_VER)
1012#pragma warning(push)
1013#pragma warning(disable : 4101)
1015 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1016 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1017#if defined(_MSC_VER)
1024 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_subtract;
1025 binaryfunc slot2 = NULL;
1027 if (!(&PyLong_Type == type2)) {
1031 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_subtract : NULL;
1033 if (slot1 == slot2) {
1038 if (slot1 != NULL) {
1039 if (slot2 != NULL) {
1040 if (Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
1041 PyObject *x = slot2(*operand1, operand2);
1043 if (x != Py_NotImplemented) {
1045 goto exit_inplace_result_object;
1048 Py_DECREF_IMMORTAL(x);
1053 PyObject *x = slot1(*operand1, operand2);
1055 if (x != Py_NotImplemented) {
1057 goto exit_inplace_result_object;
1060 Py_DECREF_IMMORTAL(x);
1063 if (slot2 != NULL) {
1064 PyObject *x = slot2(*operand1, operand2);
1066 if (x != Py_NotImplemented) {
1068 goto exit_inplace_result_object;
1071 Py_DECREF_IMMORTAL(x);
1074#if PYTHON_VERSION < 0x300
1075 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1076 coercion c1 = PyLong_Type.tp_as_number->nb_coerce;
1079 PyObject *coerced1 = *operand1;
1080 PyObject *coerced2 = operand2;
1082 int err = c1(&coerced1, &coerced2);
1084 if (unlikely(err < 0)) {
1085 goto exit_inplace_exception;
1089 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1091 if (likely(mv == NULL)) {
1092 binaryfunc slot = mv->nb_subtract;
1094 if (likely(slot != NULL)) {
1095 PyObject *x = slot(coerced1, coerced2);
1097 Py_DECREF(coerced1);
1098 Py_DECREF(coerced2);
1101 goto exit_inplace_result_object;
1106 Py_DECREF(coerced1);
1107 Py_DECREF(coerced2);
1111 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1114 PyObject *coerced1 = *operand1;
1115 PyObject *coerced2 = operand2;
1117 int err = c2(&coerced2, &coerced1);
1119 if (unlikely(err < 0)) {
1120 goto exit_inplace_exception;
1124 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1126 if (likely(mv == NULL)) {
1127 binaryfunc slot = mv->nb_subtract;
1129 if (likely(slot != NULL)) {
1130 PyObject *x = slot(coerced1, coerced2);
1132 Py_DECREF(coerced1);
1133 Py_DECREF(coerced2);
1136 goto exit_inplace_result_object;
1141 Py_DECREF(coerced1);
1142 Py_DECREF(coerced2);
1148#if PYTHON_VERSION < 0x300
1149 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'long' and '%s'", type2->tp_name);
1151 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'int' and '%s'", type2->tp_name);
1153 goto exit_inplace_exception;
1156exit_inplace_result_object:
1157 if (unlikely(obj_result == NULL)) {
1162 Py_DECREF(*operand1);
1166 *operand1 = obj_result;
1170exit_inplace_exception:
1173static inline bool _INPLACE_OPERATION_SUB_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
1176 CHECK_OBJECT(*operand1);
1177 assert(PyLong_CheckExact(*operand1));
1178 CHECK_OBJECT(operand2);
1180 PyTypeObject *type2 = Py_TYPE(operand2);
1182 if (&PyLong_Type == type2) {
1186#if defined(_MSC_VER)
1187#pragma warning(push)
1188#pragma warning(disable : 4101)
1190 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1191 NUITKA_MAY_BE_UNUSED
long clong_result;
1192#if defined(_MSC_VER)
1196 PyLongObject *operand1_long_object = (PyLongObject *)*operand1;
1198 PyLongObject *operand2_long_object = (PyLongObject *)operand2;
1200 if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && Nuitka_LongGetDigitSize(operand2_long_object) <= 1) {
1201 long r = (long)(MEDIUM_VALUE(operand1_long_object) - MEDIUM_VALUE(operand2_long_object));
1203 if (Py_REFCNT(*operand1) == 1) {
1204 Nuitka_LongUpdateFromCLong(&*operand1, r);
1205 goto exit_result_ok;
1207 PyObject *obj = Nuitka_LongFromCLong(r);
1210 goto exit_result_object;
1213 goto exit_result_ok_clong;
1216 if (Py_REFCNT(*operand1) == 1) {
1217 digit
const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
1218 Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
1220 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
1221 bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
1225 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, -1);
1227 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
1228 Nuitka_LongSetSignNegative(*operand1);
1232 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
1234 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, 1);
1238 goto exit_result_ok;
1243 digit
const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
1244 Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
1245 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
1246 digit
const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
1247 Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
1248 bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
1252 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
1254 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
1257 Nuitka_LongFlipSign(z);
1260 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
1262 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
1266 obj_result = (PyObject *)z;
1267 goto exit_result_object;
1271 if (unlikely(obj_result == NULL)) {
1272 goto exit_result_exception;
1275 Py_DECREF(*operand1);
1276 *operand1 = obj_result;
1277 goto exit_result_ok;
1279 exit_result_ok_clong:
1282 Py_DECREF(*operand1);
1286 *operand1 = Nuitka_PyLong_FromLong(clong_result);
1287 goto exit_result_ok;
1292 exit_result_exception:
1296 return __INPLACE_OPERATION_SUB_LONG_OBJECT(operand1, operand2);
1299bool INPLACE_OPERATION_SUB_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
1300 return _INPLACE_OPERATION_SUB_LONG_OBJECT(operand1, operand2);
1304static inline bool _INPLACE_OPERATION_SUB_FLOAT_FLOAT(PyObject **operand1, PyObject *operand2) {
1307 CHECK_OBJECT(*operand1);
1308 assert(PyFloat_CheckExact(*operand1));
1309 CHECK_OBJECT(operand2);
1310 assert(PyFloat_CheckExact(operand2));
1312#if defined(_MSC_VER)
1313#pragma warning(push)
1314#pragma warning(disable : 4101)
1317 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1318 NUITKA_MAY_BE_UNUSED
long clong_result;
1319 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1320#if defined(_MSC_VER)
1324 CHECK_OBJECT(*operand1);
1325 assert(PyFloat_CheckExact(*operand1));
1326 CHECK_OBJECT(operand2);
1327 assert(PyFloat_CheckExact(operand2));
1329 const double a = PyFloat_AS_DOUBLE(*operand1);
1330 const double b = PyFloat_AS_DOUBLE(operand2);
1335 goto exit_result_ok_cfloat;
1337exit_result_ok_cfloat:
1338 if (Py_REFCNT(*operand1) == 1) {
1339 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
1342 Py_DECREF(*operand1);
1344 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
1346 goto exit_result_ok;
1352bool INPLACE_OPERATION_SUB_FLOAT_FLOAT(PyObject **operand1, PyObject *operand2) {
1353 return _INPLACE_OPERATION_SUB_FLOAT_FLOAT(operand1, operand2);
1357static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_SUB_OBJECT_FLOAT(PyObject **operand1, PyObject *operand2) {
1358 PyTypeObject *type1 = Py_TYPE(*operand1);
1360#if defined(_MSC_VER)
1361#pragma warning(push)
1362#pragma warning(disable : 4101)
1364 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1365 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1366#if defined(_MSC_VER)
1371 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_subtract : NULL;
1373 if (islot != NULL) {
1374 PyObject *x = islot(*operand1, operand2);
1376 if (x != Py_NotImplemented) {
1378 goto exit_inplace_result_object;
1381 Py_DECREF_IMMORTAL(x);
1386 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_subtract : NULL;
1387 binaryfunc slot2 = NULL;
1389 if (!(type1 == &PyFloat_Type)) {
1392 slot2 = PyFloat_Type.tp_as_number->nb_subtract;
1394 if (slot1 == slot2) {
1399 if (slot1 != NULL) {
1400 PyObject *x = slot1(*operand1, operand2);
1402 if (x != Py_NotImplemented) {
1404 goto exit_inplace_result_object;
1407 Py_DECREF_IMMORTAL(x);
1410 if (slot2 != NULL) {
1411 PyObject *x = slot2(*operand1, operand2);
1413 if (x != Py_NotImplemented) {
1415 goto exit_inplace_result_object;
1418 Py_DECREF_IMMORTAL(x);
1421#if PYTHON_VERSION < 0x300
1422 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
1424 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1427 PyObject *coerced1 = *operand1;
1428 PyObject *coerced2 = operand2;
1430 int err = c1(&coerced1, &coerced2);
1432 if (unlikely(err < 0)) {
1433 goto exit_inplace_exception;
1437 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1439 if (likely(mv == NULL)) {
1440 binaryfunc slot = mv->nb_subtract;
1442 if (likely(slot != NULL)) {
1443 PyObject *x = slot(coerced1, coerced2);
1445 Py_DECREF(coerced1);
1446 Py_DECREF(coerced2);
1449 goto exit_inplace_result_object;
1454 Py_DECREF(coerced1);
1455 Py_DECREF(coerced2);
1458 coercion c2 = PyFloat_Type.tp_as_number->nb_coerce;
1461 PyObject *coerced1 = *operand1;
1462 PyObject *coerced2 = operand2;
1464 int err = c2(&coerced2, &coerced1);
1466 if (unlikely(err < 0)) {
1467 goto exit_inplace_exception;
1471 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1473 if (likely(mv == NULL)) {
1474 binaryfunc slot = mv->nb_subtract;
1476 if (likely(slot != NULL)) {
1477 PyObject *x = slot(coerced1, coerced2);
1479 Py_DECREF(coerced1);
1480 Py_DECREF(coerced2);
1483 goto exit_inplace_result_object;
1488 Py_DECREF(coerced1);
1489 Py_DECREF(coerced2);
1495 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: '%s' and 'float'", type1->tp_name);
1496 goto exit_inplace_exception;
1499exit_inplace_result_object:
1500 if (unlikely(obj_result == NULL)) {
1505 Py_DECREF(*operand1);
1509 *operand1 = obj_result;
1513exit_inplace_exception:
1516static inline bool _INPLACE_OPERATION_SUB_OBJECT_FLOAT(PyObject **operand1, PyObject *operand2) {
1519 CHECK_OBJECT(*operand1);
1520 CHECK_OBJECT(operand2);
1521 assert(PyFloat_CheckExact(operand2));
1523 PyTypeObject *type1 = Py_TYPE(*operand1);
1525 if (type1 == &PyFloat_Type) {
1528#if defined(_MSC_VER)
1529#pragma warning(push)
1530#pragma warning(disable : 4101)
1533 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1534 NUITKA_MAY_BE_UNUSED
long clong_result;
1535 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1536#if defined(_MSC_VER)
1540 CHECK_OBJECT(*operand1);
1541 assert(PyFloat_CheckExact(*operand1));
1542 CHECK_OBJECT(operand2);
1543 assert(PyFloat_CheckExact(operand2));
1545 const double a = PyFloat_AS_DOUBLE(*operand1);
1546 const double b = PyFloat_AS_DOUBLE(operand2);
1551 goto exit_result_ok_cfloat;
1553 exit_result_ok_cfloat:
1554 if (Py_REFCNT(*operand1) == 1) {
1555 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
1558 Py_DECREF(*operand1);
1560 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
1562 goto exit_result_ok;
1568 return __INPLACE_OPERATION_SUB_OBJECT_FLOAT(operand1, operand2);
1571bool INPLACE_OPERATION_SUB_OBJECT_FLOAT(PyObject **operand1, PyObject *operand2) {
1572 return _INPLACE_OPERATION_SUB_OBJECT_FLOAT(operand1, operand2);
1576static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_SUB_FLOAT_OBJECT(PyObject **operand1, PyObject *operand2) {
1577 PyTypeObject *type2 = Py_TYPE(operand2);
1579#if defined(_MSC_VER)
1580#pragma warning(push)
1581#pragma warning(disable : 4101)
1583 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1584 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1585#if defined(_MSC_VER)
1592 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_subtract;
1593 binaryfunc slot2 = NULL;
1595 if (!(&PyFloat_Type == type2)) {
1599 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_subtract : NULL;
1601 if (slot1 == slot2) {
1606 if (slot1 != NULL) {
1607 if (slot2 != NULL) {
1608 if (Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
1609 PyObject *x = slot2(*operand1, operand2);
1611 if (x != Py_NotImplemented) {
1613 goto exit_inplace_result_object;
1616 Py_DECREF_IMMORTAL(x);
1621 PyObject *x = slot1(*operand1, operand2);
1623 if (x != Py_NotImplemented) {
1625 goto exit_inplace_result_object;
1628 Py_DECREF_IMMORTAL(x);
1631 if (slot2 != NULL) {
1632 PyObject *x = slot2(*operand1, operand2);
1634 if (x != Py_NotImplemented) {
1636 goto exit_inplace_result_object;
1639 Py_DECREF_IMMORTAL(x);
1642#if PYTHON_VERSION < 0x300
1643 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1644 coercion c1 = PyFloat_Type.tp_as_number->nb_coerce;
1647 PyObject *coerced1 = *operand1;
1648 PyObject *coerced2 = operand2;
1650 int err = c1(&coerced1, &coerced2);
1652 if (unlikely(err < 0)) {
1653 goto exit_inplace_exception;
1657 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1659 if (likely(mv == NULL)) {
1660 binaryfunc slot = mv->nb_subtract;
1662 if (likely(slot != NULL)) {
1663 PyObject *x = slot(coerced1, coerced2);
1665 Py_DECREF(coerced1);
1666 Py_DECREF(coerced2);
1669 goto exit_inplace_result_object;
1674 Py_DECREF(coerced1);
1675 Py_DECREF(coerced2);
1679 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1682 PyObject *coerced1 = *operand1;
1683 PyObject *coerced2 = operand2;
1685 int err = c2(&coerced2, &coerced1);
1687 if (unlikely(err < 0)) {
1688 goto exit_inplace_exception;
1692 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1694 if (likely(mv == NULL)) {
1695 binaryfunc slot = mv->nb_subtract;
1697 if (likely(slot != NULL)) {
1698 PyObject *x = slot(coerced1, coerced2);
1700 Py_DECREF(coerced1);
1701 Py_DECREF(coerced2);
1704 goto exit_inplace_result_object;
1709 Py_DECREF(coerced1);
1710 Py_DECREF(coerced2);
1716 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'float' and '%s'", type2->tp_name);
1717 goto exit_inplace_exception;
1720exit_inplace_result_object:
1721 if (unlikely(obj_result == NULL)) {
1726 Py_DECREF(*operand1);
1730 *operand1 = obj_result;
1734exit_inplace_exception:
1737static inline bool _INPLACE_OPERATION_SUB_FLOAT_OBJECT(PyObject **operand1, PyObject *operand2) {
1740 CHECK_OBJECT(*operand1);
1741 assert(PyFloat_CheckExact(*operand1));
1742 CHECK_OBJECT(operand2);
1744 PyTypeObject *type2 = Py_TYPE(operand2);
1746 if (&PyFloat_Type == type2) {
1749#if defined(_MSC_VER)
1750#pragma warning(push)
1751#pragma warning(disable : 4101)
1754 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1755 NUITKA_MAY_BE_UNUSED
long clong_result;
1756 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1757#if defined(_MSC_VER)
1761 CHECK_OBJECT(*operand1);
1762 assert(PyFloat_CheckExact(*operand1));
1763 CHECK_OBJECT(operand2);
1764 assert(PyFloat_CheckExact(operand2));
1766 const double a = PyFloat_AS_DOUBLE(*operand1);
1767 const double b = PyFloat_AS_DOUBLE(operand2);
1772 goto exit_result_ok_cfloat;
1774 exit_result_ok_cfloat:
1775 if (Py_REFCNT(*operand1) == 1) {
1776 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
1779 Py_DECREF(*operand1);
1781 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
1783 goto exit_result_ok;
1789 return __INPLACE_OPERATION_SUB_FLOAT_OBJECT(operand1, operand2);
1792bool INPLACE_OPERATION_SUB_FLOAT_OBJECT(PyObject **operand1, PyObject *operand2) {
1793 return _INPLACE_OPERATION_SUB_FLOAT_OBJECT(operand1, operand2);
1797static inline bool _INPLACE_OPERATION_SUB_FLOAT_LONG(PyObject **operand1, PyObject *operand2) {
1800 CHECK_OBJECT(*operand1);
1801 assert(PyFloat_CheckExact(*operand1));
1802 CHECK_OBJECT(operand2);
1803 assert(PyLong_CheckExact(operand2));
1805#if defined(_MSC_VER)
1806#pragma warning(push)
1807#pragma warning(disable : 4101)
1809 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1810 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1811#if defined(_MSC_VER)
1818 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_subtract;
1821 if (slot1 != NULL) {
1822 PyObject *x = slot1(*operand1, operand2);
1824 if (x != Py_NotImplemented) {
1826 goto exit_inplace_result_object;
1829 Py_DECREF_IMMORTAL(x);
1834#if PYTHON_VERSION < 0x300
1835 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'float' and 'long'");
1837 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'float' and 'int'");
1839 goto exit_inplace_exception;
1842exit_inplace_result_object:
1843 if (unlikely(obj_result == NULL)) {
1848 Py_DECREF(*operand1);
1852 *operand1 = obj_result;
1856exit_inplace_exception:
1860bool INPLACE_OPERATION_SUB_FLOAT_LONG(PyObject **operand1, PyObject *operand2) {
1861 return _INPLACE_OPERATION_SUB_FLOAT_LONG(operand1, operand2);
1865static inline bool _INPLACE_OPERATION_SUB_LONG_FLOAT(PyObject **operand1, PyObject *operand2) {
1868 CHECK_OBJECT(*operand1);
1869 assert(PyLong_CheckExact(*operand1));
1870 CHECK_OBJECT(operand2);
1871 assert(PyFloat_CheckExact(operand2));
1873#if defined(_MSC_VER)
1874#pragma warning(push)
1875#pragma warning(disable : 4101)
1877 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1878 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1879#if defined(_MSC_VER)
1887 binaryfunc slot2 = NULL;
1892 slot2 = PyFloat_Type.tp_as_number->nb_subtract;
1895 if (slot2 != NULL) {
1896 PyObject *x = slot2(*operand1, operand2);
1898 if (x != Py_NotImplemented) {
1900 goto exit_inplace_result_object;
1903 Py_DECREF_IMMORTAL(x);
1908#if PYTHON_VERSION < 0x300
1909 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'long' and 'float'");
1911 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'int' and 'float'");
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:
1934bool INPLACE_OPERATION_SUB_LONG_FLOAT(PyObject **operand1, PyObject *operand2) {
1935 return _INPLACE_OPERATION_SUB_LONG_FLOAT(operand1, operand2);
1938#if PYTHON_VERSION < 0x300
1940static inline bool _INPLACE_OPERATION_SUB_FLOAT_INT(PyObject **operand1, PyObject *operand2) {
1943 CHECK_OBJECT(*operand1);
1944 assert(PyFloat_CheckExact(*operand1));
1945 CHECK_OBJECT(operand2);
1946 assert(PyInt_CheckExact(operand2));
1948#if defined(_MSC_VER)
1949#pragma warning(push)
1950#pragma warning(disable : 4101)
1952 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1953 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1954#if defined(_MSC_VER)
1961 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_subtract;
1964 if (slot1 != NULL) {
1965 PyObject *x = slot1(*operand1, operand2);
1967 if (x != Py_NotImplemented) {
1969 goto exit_inplace_result_object;
1972 Py_DECREF_IMMORTAL(x);
1977 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'float' and 'int'");
1978 goto exit_inplace_exception;
1981exit_inplace_result_object:
1982 if (unlikely(obj_result == NULL)) {
1987 Py_DECREF(*operand1);
1991 *operand1 = obj_result;
1995exit_inplace_exception:
1999bool INPLACE_OPERATION_SUB_FLOAT_INT(PyObject **operand1, PyObject *operand2) {
2000 return _INPLACE_OPERATION_SUB_FLOAT_INT(operand1, operand2);
2004#if PYTHON_VERSION < 0x300
2006static inline bool _INPLACE_OPERATION_SUB_INT_FLOAT(PyObject **operand1, PyObject *operand2) {
2009 CHECK_OBJECT(*operand1);
2010 assert(PyInt_CheckExact(*operand1));
2011 CHECK_OBJECT(operand2);
2012 assert(PyFloat_CheckExact(operand2));
2014#if defined(_MSC_VER)
2015#pragma warning(push)
2016#pragma warning(disable : 4101)
2018 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2019 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2020#if defined(_MSC_VER)
2028 binaryfunc slot2 = NULL;
2033 slot2 = PyFloat_Type.tp_as_number->nb_subtract;
2036 if (slot2 != NULL) {
2037 PyObject *x = slot2(*operand1, operand2);
2039 if (x != Py_NotImplemented) {
2041 goto exit_inplace_result_object;
2044 Py_DECREF_IMMORTAL(x);
2049 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'int' and 'float'");
2050 goto exit_inplace_exception;
2053exit_inplace_result_object:
2054 if (unlikely(obj_result == NULL)) {
2059 Py_DECREF(*operand1);
2063 *operand1 = obj_result;
2067exit_inplace_exception:
2071bool INPLACE_OPERATION_SUB_INT_FLOAT(PyObject **operand1, PyObject *operand2) {
2072 return _INPLACE_OPERATION_SUB_INT_FLOAT(operand1, operand2);
2076#if PYTHON_VERSION < 0x300
2078static inline bool _INPLACE_OPERATION_SUB_LONG_INT(PyObject **operand1, PyObject *operand2) {
2081 CHECK_OBJECT(*operand1);
2082 assert(PyLong_CheckExact(*operand1));
2083 CHECK_OBJECT(operand2);
2084 assert(PyInt_CheckExact(operand2));
2086#if defined(_MSC_VER)
2087#pragma warning(push)
2088#pragma warning(disable : 4101)
2090 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2091 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2092#if defined(_MSC_VER)
2099 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_subtract;
2102 if (slot1 != NULL) {
2103 PyObject *x = slot1(*operand1, operand2);
2105 if (x != Py_NotImplemented) {
2107 goto exit_inplace_result_object;
2110 Py_DECREF_IMMORTAL(x);
2115 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'long' and 'int'");
2116 goto exit_inplace_exception;
2119exit_inplace_result_object:
2120 if (unlikely(obj_result == NULL)) {
2125 Py_DECREF(*operand1);
2129 *operand1 = obj_result;
2133exit_inplace_exception:
2137bool INPLACE_OPERATION_SUB_LONG_INT(PyObject **operand1, PyObject *operand2) {
2138 return _INPLACE_OPERATION_SUB_LONG_INT(operand1, operand2);
2142#if PYTHON_VERSION < 0x300
2144static inline bool _INPLACE_OPERATION_SUB_INT_LONG(PyObject **operand1, PyObject *operand2) {
2147 CHECK_OBJECT(*operand1);
2148 assert(PyInt_CheckExact(*operand1));
2149 CHECK_OBJECT(operand2);
2150 assert(PyLong_CheckExact(operand2));
2152#if defined(_MSC_VER)
2153#pragma warning(push)
2154#pragma warning(disable : 4101)
2156 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2157 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2158#if defined(_MSC_VER)
2166 binaryfunc slot2 = NULL;
2171 slot2 = PyLong_Type.tp_as_number->nb_subtract;
2174 if (slot2 != NULL) {
2175 PyObject *x = slot2(*operand1, operand2);
2177 if (x != Py_NotImplemented) {
2179 goto exit_inplace_result_object;
2182 Py_DECREF_IMMORTAL(x);
2187 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: 'int' and 'long'");
2188 goto exit_inplace_exception;
2191exit_inplace_result_object:
2192 if (unlikely(obj_result == NULL)) {
2197 Py_DECREF(*operand1);
2201 *operand1 = obj_result;
2205exit_inplace_exception:
2209bool INPLACE_OPERATION_SUB_INT_LONG(PyObject **operand1, PyObject *operand2) {
2210 return _INPLACE_OPERATION_SUB_INT_LONG(operand1, operand2);
2214#if PYTHON_VERSION < 0x300
2216static inline bool _INPLACE_OPERATION_SUB_INT_CLONG(PyObject **operand1,
long operand2) {
2219 CHECK_OBJECT(*operand1);
2220 assert(PyInt_CheckExact(*operand1));
2223#if defined(_MSC_VER)
2224#pragma warning(push)
2225#pragma warning(disable : 4101)
2227 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2228 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2229 NUITKA_MAY_BE_UNUSED
long clong_result;
2230 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2231#if defined(_MSC_VER)
2235 CHECK_OBJECT(*operand1);
2236 assert(PyInt_CheckExact(*operand1));
2238 const long a = PyInt_AS_LONG(*operand1);
2239 const long b = operand2;
2241 const long x = (long)((
unsigned long)a - b);
2242 bool no_overflow = ((x ^ a) >= 0 || (x ^ ~b) >= 0);
2243 if (likely(no_overflow)) {
2245 goto exit_result_ok_clong;
2249 PyObject *operand1_object = *operand1;
2250 PyObject *operand2_object = Nuitka_PyLong_FromLong(operand2);
2252 PyObject *r = PyLong_Type.tp_as_number->nb_subtract(operand1_object, operand2_object);
2253 assert(r != Py_NotImplemented);
2255 Py_DECREF(operand2_object);
2258 goto exit_result_object;
2261exit_result_ok_clong:
2264 Py_DECREF(*operand1);
2268 *operand1 = Nuitka_PyInt_FromLong(clong_result);
2269 goto exit_result_ok;
2272 if (unlikely(obj_result == NULL)) {
2273 goto exit_result_exception;
2276 Py_DECREF(*operand1);
2278 *operand1 = obj_result;
2279 goto exit_result_ok;
2284exit_result_exception:
2288bool INPLACE_OPERATION_SUB_INT_CLONG(PyObject **operand1,
long operand2) {
2289 return _INPLACE_OPERATION_SUB_INT_CLONG(operand1, operand2);
2295static inline bool _INPLACE_OPERATION_SUB_LONG_DIGIT(PyObject **operand1,
long operand2) {
2298 CHECK_OBJECT(*operand1);
2299 assert(PyLong_CheckExact(*operand1));
2300 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
2303#if defined(_MSC_VER)
2304#pragma warning(push)
2305#pragma warning(disable : 4101)
2307 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2308 NUITKA_MAY_BE_UNUSED
long clong_result;
2309#if defined(_MSC_VER)
2313 PyLongObject *operand1_long_object = (PyLongObject *)*operand1;
2315 if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && (operand2 == 0 ? 0 : 1) <= 1) {
2316 long r = (long)(MEDIUM_VALUE(operand1_long_object) - (sdigit)operand2);
2318 if (Py_REFCNT(*operand1) == 1) {
2319 Nuitka_LongUpdateFromCLong(&*operand1, r);
2320 goto exit_result_ok;
2322 PyObject *obj = Nuitka_LongFromCLong(r);
2325 goto exit_result_object;
2328 goto exit_result_ok_clong;
2331 if (Py_REFCNT(*operand1) == 1) {
2332 digit
const *b_digits = (digit *)&operand2;
2333 Py_ssize_t b_digit_count = (operand2 == 0 ? 0 : 1);
2335 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
2336 bool b_negative = operand2 < 0;
2340 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, -1);
2342 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
2343 Nuitka_LongSetSignNegative(*operand1);
2347 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
2349 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, 1);
2353 goto exit_result_ok;
2358 digit
const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
2359 Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
2360 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
2361 digit
const *b_digits = (digit *)&operand2;
2362 Py_ssize_t b_digit_count = (operand2 == 0 ? 0 : 1);
2363 bool b_negative = operand2 < 0;
2367 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
2369 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
2372 Nuitka_LongFlipSign(z);
2375 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
2377 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
2381 obj_result = (PyObject *)z;
2382 goto exit_result_object;
2386 if (unlikely(obj_result == NULL)) {
2387 goto exit_result_exception;
2390 Py_DECREF(*operand1);
2391 *operand1 = obj_result;
2392 goto exit_result_ok;
2394exit_result_ok_clong:
2397 Py_DECREF(*operand1);
2401 *operand1 = Nuitka_PyLong_FromLong(clong_result);
2402 goto exit_result_ok;
2407exit_result_exception:
2411bool INPLACE_OPERATION_SUB_LONG_DIGIT(PyObject **operand1,
long operand2) {
2412 return _INPLACE_OPERATION_SUB_LONG_DIGIT(operand1, operand2);
2416static inline bool _INPLACE_OPERATION_SUB_LONG_CLONG(PyObject **operand1,
long operand2) {
2419 CHECK_OBJECT(*operand1);
2420 assert(PyLong_CheckExact(*operand1));
2423#if defined(_MSC_VER)
2424#pragma warning(push)
2425#pragma warning(disable : 4101)
2427 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2428 NUITKA_MAY_BE_UNUSED
long clong_result;
2429#if defined(_MSC_VER)
2433 PyLongObject *operand1_long_object = (PyLongObject *)*operand1;
2435 bool operand2_is_negative;
2436 unsigned long operand2_abs_ival;
2439 operand2_abs_ival = (
unsigned long)(-1 - operand2) + 1;
2440 operand2_is_negative =
true;
2442 operand2_abs_ival = (
unsigned long)operand2;
2443 operand2_is_negative =
false;
2446 Py_ssize_t operand2_digit_count = 0;
2447 digit operand2_digits[5] = {0};
2449 unsigned long t = operand2_abs_ival;
2452 operand2_digit_count += 1;
2453 assert(operand2_digit_count <= (Py_ssize_t)(
sizeof(operand2_digit_count) /
sizeof(digit)));
2455 operand2_digits[operand2_digit_count] = (digit)(t & PyLong_MASK);
2460 NUITKA_MAY_BE_UNUSED Py_ssize_t operand2_size =
2461 operand2_is_negative ==
false ? operand2_digit_count : -operand2_digit_count;
2463 if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && operand2_digit_count <= 1) {
2464 long r = (long)(MEDIUM_VALUE(operand1_long_object) - (sdigit)operand2);
2466 if (Py_REFCNT(*operand1) == 1) {
2467 Nuitka_LongUpdateFromCLong(&*operand1, r);
2468 goto exit_result_ok;
2470 PyObject *obj = Nuitka_LongFromCLong(r);
2473 goto exit_result_object;
2476 goto exit_result_ok_clong;
2479 if (Py_REFCNT(*operand1) == 1) {
2480 digit
const *b_digits = operand2_digits;
2481 Py_ssize_t b_digit_count = operand2_digit_count;
2483 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
2484 bool b_negative = operand2_is_negative;
2488 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, -1);
2490 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
2491 Nuitka_LongSetSignNegative(*operand1);
2495 *operand1 = _Nuitka_LongAddInplaceDigits(*operand1, b_digits, b_digit_count);
2497 *operand1 = _Nuitka_LongSubInplaceDigits(*operand1, b_digits, b_digit_count, 1);
2501 goto exit_result_ok;
2506 digit
const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
2507 Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
2508 bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
2509 digit
const *b_digits = operand2_digits;
2510 Py_ssize_t b_digit_count = operand2_digit_count;
2511 bool b_negative = operand2_is_negative;
2515 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
2517 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
2520 Nuitka_LongFlipSign(z);
2523 z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
2525 z = _Nuitka_LongSubDigits(a_digits, a_digit_count, b_digits, b_digit_count);
2529 obj_result = (PyObject *)z;
2530 goto exit_result_object;
2534 if (unlikely(obj_result == NULL)) {
2535 goto exit_result_exception;
2538 Py_DECREF(*operand1);
2539 *operand1 = obj_result;
2540 goto exit_result_ok;
2542exit_result_ok_clong:
2545 Py_DECREF(*operand1);
2549 *operand1 = Nuitka_PyLong_FromLong(clong_result);
2550 goto exit_result_ok;
2555exit_result_exception:
2559bool INPLACE_OPERATION_SUB_LONG_CLONG(PyObject **operand1,
long operand2) {
2560 return _INPLACE_OPERATION_SUB_LONG_CLONG(operand1, operand2);
2564static inline bool _INPLACE_OPERATION_SUB_FLOAT_CFLOAT(PyObject **operand1,
double operand2) {
2567 CHECK_OBJECT(*operand1);
2568 assert(PyFloat_CheckExact(*operand1));
2570#if defined(_MSC_VER)
2571#pragma warning(push)
2572#pragma warning(disable : 4101)
2575 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2576 NUITKA_MAY_BE_UNUSED
long clong_result;
2577 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2578#if defined(_MSC_VER)
2582 CHECK_OBJECT(*operand1);
2583 assert(PyFloat_CheckExact(*operand1));
2585 const double a = PyFloat_AS_DOUBLE(*operand1);
2586 const double b = operand2;
2591 goto exit_result_ok_cfloat;
2593exit_result_ok_cfloat:
2594 if (Py_REFCNT(*operand1) == 1) {
2595 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
2598 Py_DECREF(*operand1);
2600 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
2602 goto exit_result_ok;
2608bool INPLACE_OPERATION_SUB_FLOAT_CFLOAT(PyObject **operand1,
double operand2) {
2609 return _INPLACE_OPERATION_SUB_FLOAT_CFLOAT(operand1, operand2);
2613static inline bool _INPLACE_OPERATION_SUB_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
2616 CHECK_OBJECT(*operand1);
2617 CHECK_OBJECT(operand2);
2619#if PYTHON_VERSION < 0x300
2620 if (PyInt_CheckExact(*operand1) && PyInt_CheckExact(operand2)) {
2623#if defined(_MSC_VER)
2624#pragma warning(push)
2625#pragma warning(disable : 4101)
2627 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2628 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2629 NUITKA_MAY_BE_UNUSED
long clong_result;
2630 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2631#if defined(_MSC_VER)
2635 CHECK_OBJECT(*operand1);
2636 assert(PyInt_CheckExact(*operand1));
2637 CHECK_OBJECT(operand2);
2638 assert(PyInt_CheckExact(operand2));
2640 const long a = PyInt_AS_LONG(*operand1);
2641 const long b = PyInt_AS_LONG(operand2);
2643 const long x = (long)((
unsigned long)a - b);
2644 bool no_overflow = ((x ^ a) >= 0 || (x ^ ~b) >= 0);
2645 if (likely(no_overflow)) {
2647 goto exit_result_ok_clong;
2651 PyObject *operand1_object = *operand1;
2652 PyObject *operand2_object = operand2;
2654 PyObject *r = PyLong_Type.tp_as_number->nb_subtract(operand1_object, operand2_object);
2655 assert(r != Py_NotImplemented);
2658 goto exit_result_object;
2661 exit_result_ok_clong:
2664 Py_DECREF(*operand1);
2668 *operand1 = Nuitka_PyInt_FromLong(clong_result);
2669 goto exit_result_ok;
2672 if (unlikely(obj_result == NULL)) {
2673 goto exit_result_exception;
2676 Py_DECREF(*operand1);
2678 *operand1 = obj_result;
2679 goto exit_result_ok;
2684 exit_result_exception:
2689 if (Py_TYPE(*operand1) == Py_TYPE(operand2)) {
2690 if (PyFloat_CheckExact(operand2)) {
2691 return _INPLACE_OPERATION_SUB_FLOAT_FLOAT(operand1, operand2);
2693#if PYTHON_VERSION >= 0x300
2694 if (PyLong_CheckExact(operand2)) {
2695 return _INPLACE_OPERATION_SUB_LONG_LONG(operand1, operand2);
2700 PyTypeObject *type1 = Py_TYPE(*operand1);
2701 PyTypeObject *type2 = Py_TYPE(operand2);
2703#if defined(_MSC_VER)
2704#pragma warning(push)
2705#pragma warning(disable : 4101)
2707 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2708 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2709#if defined(_MSC_VER)
2714 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_subtract : NULL;
2716 if (islot != NULL) {
2717 PyObject *x = islot(*operand1, operand2);
2719 if (x != Py_NotImplemented) {
2721 goto exit_inplace_result_object;
2724 Py_DECREF_IMMORTAL(x);
2729 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_subtract : NULL;
2730 binaryfunc slot2 = NULL;
2732 if (!(type1 == type2)) {
2736 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_subtract : NULL;
2738 if (slot1 == slot2) {
2743 if (slot1 != NULL) {
2744 if (slot2 != NULL) {
2745 if (Nuitka_Type_IsSubtype(type2, type1)) {
2746 PyObject *x = slot2(*operand1, operand2);
2748 if (x != Py_NotImplemented) {
2750 goto exit_inplace_result_object;
2753 Py_DECREF_IMMORTAL(x);
2758 PyObject *x = slot1(*operand1, operand2);
2760 if (x != Py_NotImplemented) {
2762 goto exit_inplace_result_object;
2765 Py_DECREF_IMMORTAL(x);
2768 if (slot2 != NULL) {
2769 PyObject *x = slot2(*operand1, operand2);
2771 if (x != Py_NotImplemented) {
2773 goto exit_inplace_result_object;
2776 Py_DECREF_IMMORTAL(x);
2779#if PYTHON_VERSION < 0x300
2780 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
2782 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
2785 PyObject *coerced1 = *operand1;
2786 PyObject *coerced2 = operand2;
2788 int err = c1(&coerced1, &coerced2);
2790 if (unlikely(err < 0)) {
2791 goto exit_inplace_exception;
2795 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2797 if (likely(mv == NULL)) {
2798 binaryfunc slot = mv->nb_subtract;
2800 if (likely(slot != NULL)) {
2801 PyObject *x = slot(coerced1, coerced2);
2803 Py_DECREF(coerced1);
2804 Py_DECREF(coerced2);
2807 goto exit_inplace_result_object;
2812 Py_DECREF(coerced1);
2813 Py_DECREF(coerced2);
2817 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
2820 PyObject *coerced1 = *operand1;
2821 PyObject *coerced2 = operand2;
2823 int err = c2(&coerced2, &coerced1);
2825 if (unlikely(err < 0)) {
2826 goto exit_inplace_exception;
2830 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2832 if (likely(mv == NULL)) {
2833 binaryfunc slot = mv->nb_subtract;
2835 if (likely(slot != NULL)) {
2836 PyObject *x = slot(coerced1, coerced2);
2838 Py_DECREF(coerced1);
2839 Py_DECREF(coerced2);
2842 goto exit_inplace_result_object;
2847 Py_DECREF(coerced1);
2848 Py_DECREF(coerced2);
2854 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for -=: '%s' and '%s'", type1->tp_name,
2856 goto exit_inplace_exception;
2859exit_inplace_result_object:
2860 if (unlikely(obj_result == NULL)) {
2865 Py_DECREF(*operand1);
2869 *operand1 = obj_result;
2873exit_inplace_exception:
2877bool INPLACE_OPERATION_SUB_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
2878 return _INPLACE_OPERATION_SUB_OBJECT_OBJECT(operand1, operand2);