Serhiy Storchaka | 18b250f | 2017-03-19 08:51:07 +0200 | [diff] [blame] | 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 | { |
| 19 | PyObject *return_value = NULL; |
| 20 | static const char * const _keywords[] = {"real", "imag", NULL}; |
| 21 | static _PyArg_Parser _parser = {"|OO:complex", _keywords, 0}; |
Serhiy Storchaka | bae6881 | 2017-04-05 12:00:42 +0300 | [diff] [blame] | 22 | PyObject *r = _PyLong_Zero; |
Serhiy Storchaka | 18b250f | 2017-03-19 08:51:07 +0200 | [diff] [blame] | 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 | |
| 31 | exit: |
| 32 | return return_value; |
| 33 | } |
Serhiy Storchaka | bae6881 | 2017-04-05 12:00:42 +0300 | [diff] [blame] | 34 | /*[clinic end generated code: output=5017b2458bdc4ecd input=a9049054013a1b77]*/ |