blob: 0cbfb793e1024d4d0f07513fe9b8d3aa0792514c [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};
Serhiy Storchakabae68812017-04-05 12:00:42 +030022 PyObject *r = _PyLong_Zero;
Serhiy Storchaka18b250f2017-03-19 08:51:07 +020023 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}
Serhiy Storchakabae68812017-04-05 12:00:42 +030034/*[clinic end generated code: output=5017b2458bdc4ecd input=a9049054013a1b77]*/