3#ifndef __NUITKA_OPERATIONS_H__
4#define __NUITKA_OPERATIONS_H__
6#if PYTHON_VERSION >= 0x300
7extern PyObject *UNICODE_CONCAT(PyThreadState *tstate, PyObject *left, PyObject *right);
8extern bool UNICODE_APPEND(PyThreadState *tstate, PyObject **p_left, PyObject *right);
11NUITKA_MAY_BE_UNUSED
static PyObject *UNICODE_CONCAT(PyThreadState *tstate, PyObject *left, PyObject *right) {
12 return PyUnicode_Concat(left, right);
19#if PYTHON_VERSION < 0x300
20#define NEW_STYLE_NUMBER(o) PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_CHECKTYPES)
21#define NEW_STYLE_NUMBER_TYPE(t) PyType_HasFeature(t, Py_TPFLAGS_CHECKTYPES)
22#define CAN_HAVE_INPLACE(t) PyType_HasFeature(t, Py_TPFLAGS_HAVE_INPLACEOPS)
24#define NEW_STYLE_NUMBER(o) (true)
25#define NEW_STYLE_NUMBER_TYPE(t) (true)
26#define CAN_HAVE_INPLACE(t) (true)
29typedef PyObject *(unary_api)(PyObject *);
31NUITKA_MAY_BE_UNUSED
static PyObject *UNARY_OPERATION(unary_api api, PyObject *operand) {
32 CHECK_OBJECT(operand);
33 PyObject *result = api(operand);
35 if (unlikely(result == NULL)) {
45#include "nuitka/helper/operations_binary_add.h"
46#include "nuitka/helper/operations_binary_bitand.h"
47#include "nuitka/helper/operations_binary_bitor.h"
48#include "nuitka/helper/operations_binary_bitxor.h"
49#include "nuitka/helper/operations_binary_divmod.h"
50#include "nuitka/helper/operations_binary_floordiv.h"
51#include "nuitka/helper/operations_binary_lshift.h"
52#include "nuitka/helper/operations_binary_mod.h"
53#include "nuitka/helper/operations_binary_mult.h"
54#include "nuitka/helper/operations_binary_pow.h"
55#include "nuitka/helper/operations_binary_rshift.h"
56#include "nuitka/helper/operations_binary_sub.h"
57#include "nuitka/helper/operations_binary_truediv.h"
60#include "nuitka/helper/operations_binary_dual_add.h"
62#include "nuitka/helper/operations_inplace_add.h"
63#include "nuitka/helper/operations_inplace_bitand.h"
64#include "nuitka/helper/operations_inplace_bitor.h"
65#include "nuitka/helper/operations_inplace_bitxor.h"
66#include "nuitka/helper/operations_inplace_floordiv.h"
67#include "nuitka/helper/operations_inplace_lshift.h"
68#include "nuitka/helper/operations_inplace_mod.h"
69#include "nuitka/helper/operations_inplace_mult.h"
70#include "nuitka/helper/operations_inplace_pow.h"
71#include "nuitka/helper/operations_inplace_rshift.h"
72#include "nuitka/helper/operations_inplace_sub.h"
73#include "nuitka/helper/operations_inplace_truediv.h"
75#if PYTHON_VERSION < 0x300
77#include "nuitka/helper/operations_binary_olddiv.h"
78#include "nuitka/helper/operations_inplace_olddiv.h"
80#if PYTHON_VERSION >= 0x350
82#include "nuitka/helper/operations_binary_matmult.h"
83#include "nuitka/helper/operations_inplace_matmult.h"
88#define PyNumber_InPlaceSub PyNumber_InPlaceSubtract
89#define PyNumber_InPlaceMult PyNumber_InPlaceMultiply
90#define PyNumber_InPlaceOlddiv PyNumber_InPlaceDivide
91#define PyNumber_InPlacePow(a, b) PyNumber_InPlacePower(a, b, Py_None)
92#define PyNumber_InPlaceMod PyNumber_InPlaceRemainder
93#define PyNumber_InPlaceBitor PyNumber_InPlaceOr
94#define PyNumber_InPlaceBitxor PyNumber_InPlaceXor
95#define PyNumber_InPlaceBitand PyNumber_InPlaceAnd
96#define PyNumber_InPlaceTruediv PyNumber_InPlaceTrueDivide
97#define PyNumber_InPlaceFloordiv PyNumber_InPlaceFloorDivide
98#define PyNumber_InPlaceMatmult PyNumber_InPlaceMatrixMultiply