representation.
-.. c:function:: Py_complex _Py_cr_sum(Py_complex left, double right)
-
- Return the sum of a complex number and a real number, using the C :c:type:`Py_complex`
- representation.
-
- .. versionadded:: 3.14
-
-
.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
Return the difference between two complex numbers, using the C
:c:type:`Py_complex` representation.
-.. c:function:: Py_complex _Py_cr_diff(Py_complex left, double right)
-
- Return the difference between a complex number and a real number, using the C
- :c:type:`Py_complex` representation.
-
- .. versionadded:: 3.14
-
-
-.. c:function:: Py_complex _Py_rc_diff(double left, Py_complex right)
-
- Return the difference between a real number and a complex number, using the C
- :c:type:`Py_complex` representation.
-
- .. versionadded:: 3.14
-
-
.. c:function:: Py_complex _Py_c_neg(Py_complex num)
Return the negation of the complex number *num*, using the C
representation.
-.. c:function:: Py_complex _Py_cr_prod(Py_complex left, double right)
-
- Return the product of a complex number and a real number, using the C
- :c:type:`Py_complex` representation.
-
- .. versionadded:: 3.14
-
-
.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
Return the quotient of two complex numbers, using the C :c:type:`Py_complex`
:c:data:`errno` to :c:macro:`!EDOM`.
-.. c:function:: Py_complex _Py_cr_quot(Py_complex dividend, double divisor)
-
- Return the quotient of a complex number and a real number, using the C
- :c:type:`Py_complex` representation.
-
- If *divisor* is zero, this method returns zero and sets
- :c:data:`errno` to :c:macro:`!EDOM`.
-
- .. versionadded:: 3.14
-
-
-.. c:function:: Py_complex _Py_rc_quot(double dividend, Py_complex divisor)
-
- Return the quotient of a real number and a complex number, using the C
- :c:type:`Py_complex` representation.
-
- If *divisor* is zero, this method returns zero and sets
- :c:data:`errno` to :c:macro:`!EDOM`.
-
- .. versionadded:: 3.14
-
-
.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex`
// Operations on complex numbers.
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
-PyAPI_FUNC(Py_complex) _Py_cr_sum(Py_complex, double);
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
-PyAPI_FUNC(Py_complex) _Py_cr_diff(Py_complex, double);
-PyAPI_FUNC(Py_complex) _Py_rc_diff(double, Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
-PyAPI_FUNC(Py_complex) _Py_cr_prod(Py_complex, double);
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
-PyAPI_FUNC(Py_complex) _Py_cr_quot(Py_complex, double);
-PyAPI_FUNC(Py_complex) _Py_rc_quot(double, Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
PyAPI_FUNC(double) _Py_c_abs(Py_complex);
Py_ssize_t start,
Py_ssize_t end);
+// Operations on complex numbers.
+PyAPI_FUNC(Py_complex) _Py_cr_sum(Py_complex, double);
+PyAPI_FUNC(Py_complex) _Py_cr_diff(Py_complex, double);
+PyAPI_FUNC(Py_complex) _Py_rc_diff(double, Py_complex);
+PyAPI_FUNC(Py_complex) _Py_cr_prod(Py_complex, double);
+PyAPI_FUNC(Py_complex) _Py_cr_quot(Py_complex, double);
+PyAPI_FUNC(Py_complex) _Py_rc_quot(double, Py_complex);
+
+
#ifdef __cplusplus
}
#endif
_testcapi = import_helper.import_module('_testcapi')
_testlimitedcapi = import_helper.import_module('_testlimitedcapi')
+_testinternalcapi = import_helper.import_module('_testinternalcapi')
NULL = None
INF = float("inf")
def test_py_cr_sum(self):
# Test _Py_cr_sum()
- _py_cr_sum = _testcapi._py_cr_sum
+ _py_cr_sum = _testinternalcapi._py_cr_sum
self.assertComplexesAreIdentical(_py_cr_sum(-0j, -0.0)[0],
complex(-0.0, -0.0))
def test_py_cr_diff(self):
# Test _Py_cr_diff()
- _py_cr_diff = _testcapi._py_cr_diff
+ _py_cr_diff = _testinternalcapi._py_cr_diff
self.assertComplexesAreIdentical(_py_cr_diff(-0j, 0.0)[0],
complex(-0.0, -0.0))
def test_py_rc_diff(self):
# Test _Py_rc_diff()
- _py_rc_diff = _testcapi._py_rc_diff
+ _py_rc_diff = _testinternalcapi._py_rc_diff
self.assertComplexesAreIdentical(_py_rc_diff(-0.0, 0j)[0],
complex(-0.0, -0.0))
def test_py_cr_prod(self):
# Test _Py_cr_prod()
- _py_cr_prod = _testcapi._py_cr_prod
+ _py_cr_prod = _testinternalcapi._py_cr_prod
self.assertComplexesAreIdentical(_py_cr_prod(complex('inf+1j'), INF)[0],
complex('inf+infj'))
def test_py_cr_quot(self):
# Test _Py_cr_quot()
- _py_cr_quot = _testcapi._py_cr_quot
+ _py_cr_quot = _testinternalcapi._py_cr_quot
self.assertComplexesAreIdentical(_py_cr_quot(complex('inf+1j'), 2**1000)[0],
INF + 2**-1000*1j)
def test_py_rc_quot(self):
# Test _Py_rc_quot()
- _py_rc_quot = _testcapi._py_rc_quot
+ _py_rc_quot = _testinternalcapi._py_rc_quot
self.assertComplexesAreIdentical(_py_rc_quot(1.0, complex('nan-infj'))[0],
0j)
@MODULE_XXSUBTYPE_TRUE@xxsubtype xxsubtype.c
@MODULE__XXTESTFUZZ_TRUE@_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c
@MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c
-@MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c _testinternalcapi/test_critical_sections.c
+@MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c _testinternalcapi/test_critical_sections.c _testinternalcapi/complex.c
@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/list.c _testcapi/tuple.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/complex.c _testcapi/numbers.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/run.c _testcapi/file.c _testcapi/codec.c _testcapi/immortal.c _testcapi/gc.c _testcapi/hash.c _testcapi/time.c _testcapi/bytes.c _testcapi/object.c _testcapi/monitoring.c _testcapi/config.c _testcapi/import.c _testcapi/frame.c _testcapi/type.c _testcapi/function.c
@MODULE__TESTLIMITEDCAPI_TRUE@_testlimitedcapi _testlimitedcapi.c _testlimitedcapi/abstract.c _testlimitedcapi/bytearray.c _testlimitedcapi/bytes.c _testlimitedcapi/codec.c _testlimitedcapi/complex.c _testlimitedcapi/dict.c _testlimitedcapi/eval.c _testlimitedcapi/float.c _testlimitedcapi/heaptype_relative.c _testlimitedcapi/import.c _testlimitedcapi/list.c _testlimitedcapi/long.c _testlimitedcapi/object.c _testlimitedcapi/pyos.c _testlimitedcapi/set.c _testlimitedcapi/sys.c _testlimitedcapi/tuple.c _testlimitedcapi/unicode.c _testlimitedcapi/vectorcall_limited.c _testlimitedcapi/version.c _testlimitedcapi/file.c
@MODULE__TESTCLINIC_TRUE@_testclinic _testclinic.c
return Py_BuildValue("Di", &res, errno); \
};
-#define _PY_CR_FUNC2(suffix) \
- static PyObject * \
- _py_cr_##suffix(PyObject *Py_UNUSED(module), PyObject *args) \
- { \
- Py_complex a, res; \
- double b; \
- \
- if (!PyArg_ParseTuple(args, "Dd", &a, &b)) { \
- return NULL; \
- } \
- \
- errno = 0; \
- res = _Py_cr_##suffix(a, b); \
- return Py_BuildValue("Di", &res, errno); \
- };
-
-#define _PY_RC_FUNC2(suffix) \
- static PyObject * \
- _py_rc_##suffix(PyObject *Py_UNUSED(module), PyObject *args) \
- { \
- Py_complex b, res; \
- double a; \
- \
- if (!PyArg_ParseTuple(args, "dD", &a, &b)) { \
- return NULL; \
- } \
- \
- errno = 0; \
- res = _Py_rc_##suffix(a, b); \
- return Py_BuildValue("Di", &res, errno); \
- };
-
_PY_C_FUNC2(sum)
-_PY_CR_FUNC2(sum)
_PY_C_FUNC2(diff)
-_PY_CR_FUNC2(diff)
-_PY_RC_FUNC2(diff)
_PY_C_FUNC2(prod)
-_PY_CR_FUNC2(prod)
_PY_C_FUNC2(quot)
-_PY_CR_FUNC2(quot)
-_PY_RC_FUNC2(quot)
_PY_C_FUNC2(pow)
static PyObject*
{"complex_fromccomplex", complex_fromccomplex, METH_O},
{"complex_asccomplex", complex_asccomplex, METH_O},
{"_py_c_sum", _py_c_sum, METH_VARARGS},
- {"_py_cr_sum", _py_cr_sum, METH_VARARGS},
{"_py_c_diff", _py_c_diff, METH_VARARGS},
- {"_py_cr_diff", _py_cr_diff, METH_VARARGS},
- {"_py_rc_diff", _py_rc_diff, METH_VARARGS},
{"_py_c_neg", _py_c_neg, METH_O},
{"_py_c_prod", _py_c_prod, METH_VARARGS},
- {"_py_cr_prod", _py_cr_prod, METH_VARARGS},
{"_py_c_quot", _py_c_quot, METH_VARARGS},
- {"_py_cr_quot", _py_cr_quot, METH_VARARGS},
- {"_py_rc_quot", _py_rc_quot, METH_VARARGS},
{"_py_c_pow", _py_c_pow, METH_VARARGS},
{"_py_c_abs", _py_c_abs, METH_O},
{NULL},
if (_PyTestInternalCapi_Init_Set(module) < 0) {
return 1;
}
+ if (_PyTestInternalCapi_Init_Complex(module) < 0) {
+ return 1;
+ }
if (_PyTestInternalCapi_Init_CriticalSection(module) < 0) {
return 1;
}
--- /dev/null
+#include "parts.h"
+#include "../_testcapi/util.h"
+
+#define Py_BUILD_CORE
+#include "pycore_complexobject.h"
+
+
+#define _PY_CR_FUNC2(suffix) \
+ static PyObject * \
+ _py_cr_##suffix(PyObject *Py_UNUSED(module), PyObject *args) \
+ { \
+ Py_complex a, res; \
+ double b; \
+ \
+ if (!PyArg_ParseTuple(args, "Dd", &a, &b)) { \
+ return NULL; \
+ } \
+ \
+ errno = 0; \
+ res = _Py_cr_##suffix(a, b); \
+ return Py_BuildValue("Di", &res, errno); \
+ };
+
+#define _PY_RC_FUNC2(suffix) \
+ static PyObject * \
+ _py_rc_##suffix(PyObject *Py_UNUSED(module), PyObject *args) \
+ { \
+ Py_complex b, res; \
+ double a; \
+ \
+ if (!PyArg_ParseTuple(args, "dD", &a, &b)) { \
+ return NULL; \
+ } \
+ \
+ errno = 0; \
+ res = _Py_rc_##suffix(a, b); \
+ return Py_BuildValue("Di", &res, errno); \
+ };
+
+_PY_CR_FUNC2(sum)
+_PY_CR_FUNC2(diff)
+_PY_RC_FUNC2(diff)
+_PY_CR_FUNC2(prod)
+_PY_CR_FUNC2(quot)
+_PY_RC_FUNC2(quot)
+
+
+static PyMethodDef test_methods[] = {
+ {"_py_cr_sum", _py_cr_sum, METH_VARARGS},
+ {"_py_cr_diff", _py_cr_diff, METH_VARARGS},
+ {"_py_rc_diff", _py_rc_diff, METH_VARARGS},
+ {"_py_cr_prod", _py_cr_prod, METH_VARARGS},
+ {"_py_cr_quot", _py_cr_quot, METH_VARARGS},
+ {"_py_rc_quot", _py_rc_quot, METH_VARARGS},
+ {NULL},
+};
+
+int
+_PyTestInternalCapi_Init_Complex(PyObject *mod)
+{
+ if (PyModule_AddFunctions(mod, test_methods) < 0) {
+ return -1;
+ }
+
+ return 0;
+}
int _PyTestInternalCapi_Init_Lock(PyObject *module);
int _PyTestInternalCapi_Init_PyTime(PyObject *module);
int _PyTestInternalCapi_Init_Set(PyObject *module);
+int _PyTestInternalCapi_Init_Complex(PyObject *module);
int _PyTestInternalCapi_Init_CriticalSection(PyObject *module);
#endif // Py_TESTINTERNALCAPI_PARTS_H
<ClCompile Include="..\Modules\_testinternalcapi\test_critical_sections.c" />
<ClCompile Include="..\Modules\_testinternalcapi\test_lock.c" />
<ClCompile Include="..\Modules\_testinternalcapi\set.c" />
+ <ClCompile Include="..\Modules\_testinternalcapi\complex.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\PC\python_nt.rc" />
<ClCompile Include="..\Modules\_testinternalcapi\set.c">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\Modules\_testinternalcapi\complex.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\PC\python_nt.rc">