blob: b0b4c0e9c0770ba81f7f1adf59b593b537f36d88 [file] [log] [blame]
Serhiy Storchaka18b250f2017-03-19 08:51:07 +02001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_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
13static PyObject *
14complex_new_impl(PyTypeObject *type, PyObject *r, PyObject *i);
15
16static PyObject *
17complex_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
18{
19 PyObject *return_value = NULL;
20 static const char * const _keywords[] = {"real", "imag", NULL};
21 static _PyArg_Parser _parser = {"|OO:complex", _keywords, 0};
22 PyObject *r = Py_False;
23 PyObject *i = NULL;
24
25 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
26 &r, &i)) {
27 goto exit;
28 }
29 return_value = complex_new_impl(type, r, i);
30
31exit:
32 return return_value;
33}
34/*[clinic end generated code: output=74035493480ab5e5 input=a9049054013a1b77]*/