/src/Python-3.8.3/Objects/clinic/complexobject.c.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | PyDoc_STRVAR(complex_new__doc__, |
6 | | "complex(real=0, imag=0)\n" |
7 | | "--\n" |
8 | | "\n" |
9 | | "Create a complex number from a real part and an optional imaginary part.\n" |
10 | | "\n" |
11 | | "This is equivalent to (real + imag*1j) where imag defaults to 0."); |
12 | | |
13 | | static PyObject * |
14 | | complex_new_impl(PyTypeObject *type, PyObject *r, PyObject *i); |
15 | | |
16 | | static PyObject * |
17 | | complex_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
18 | 0 | { |
19 | 0 | PyObject *return_value = NULL; |
20 | 0 | static const char * const _keywords[] = {"real", "imag", NULL}; |
21 | 0 | static _PyArg_Parser _parser = {NULL, _keywords, "complex", 0}; |
22 | 0 | PyObject *argsbuf[2]; |
23 | 0 | PyObject * const *fastargs; |
24 | 0 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
25 | 0 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; |
26 | 0 | PyObject *r = _PyLong_Zero; |
27 | 0 | PyObject *i = NULL; |
28 | |
|
29 | 0 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); |
30 | 0 | if (!fastargs) { |
31 | 0 | goto exit; |
32 | 0 | } |
33 | 0 | if (!noptargs) { |
34 | 0 | goto skip_optional_pos; |
35 | 0 | } |
36 | 0 | if (fastargs[0]) { |
37 | 0 | r = fastargs[0]; |
38 | 0 | if (!--noptargs) { |
39 | 0 | goto skip_optional_pos; |
40 | 0 | } |
41 | 0 | } |
42 | 0 | i = fastargs[1]; |
43 | 0 | skip_optional_pos: |
44 | 0 | return_value = complex_new_impl(type, r, i); |
45 | |
|
46 | 0 | exit: |
47 | 0 | return return_value; |
48 | 0 | } |
49 | | /*[clinic end generated code: output=a0fe23fdbdc9b06b input=a9049054013a1b77]*/ |