@@ -2079,19 +2079,23 @@ builtin_repr(PyObject *module, PyObject *obj)
2079
2079
}
2080
2080
2081
2081
2082
- /* AC: cannot convert yet, as needs PEP 457 group support in inspect
2083
- * or a semantic change to accept None for "ndigits"
2084
- */
2082
+ /*[clinic input]
2083
+ round as builtin_round
2084
+
2085
+ number: object
2086
+ ndigits: object = NULL
2087
+
2088
+ Round a number to a given precision in decimal digits.
2089
+
2090
+ The return value is an integer if ndigits is omitted or None. Otherwise
2091
+ the return value has the same type as the number. ndigits may be negative.
2092
+ [clinic start generated code]*/
2093
+
2085
2094
static PyObject *
2086
- builtin_round (PyObject * self , PyObject * args , PyObject * kwds )
2095
+ builtin_round_impl (PyObject * module , PyObject * number , PyObject * ndigits )
2096
+ /*[clinic end generated code: output=ff0d9dd176c02ede input=854bc3a217530c3d]*/
2087
2097
{
2088
- PyObject * ndigits = NULL ;
2089
- static char * kwlist [] = {"number" , "ndigits" , 0 };
2090
- PyObject * number , * round , * result ;
2091
-
2092
- if (!PyArg_ParseTupleAndKeywords (args , kwds , "O|O:round" ,
2093
- kwlist , & number , & ndigits ))
2094
- return NULL ;
2098
+ PyObject * round , * result ;
2095
2099
2096
2100
if (Py_TYPE (number )-> tp_dict == NULL ) {
2097
2101
if (PyType_Ready (Py_TYPE (number )) < 0 )
@@ -2115,13 +2119,6 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
2115
2119
return result ;
2116
2120
}
2117
2121
2118
- PyDoc_STRVAR (round_doc ,
2119
- "round(number[, ndigits]) -> number\n\
2120
- \n\
2121
- Round a number to a given precision in decimal digits (default 0 digits).\n\
2122
- This returns an int when called with one argument, otherwise the\n\
2123
- same type as the number. ndigits may be negative." );
2124
-
2125
2122
2126
2123
/*AC: we need to keep the kwds dict intact to easily call into the
2127
2124
* list.sort method, which isn't currently supported in AC. So we just use
@@ -2679,7 +2676,7 @@ static PyMethodDef builtin_methods[] = {
2679
2676
BUILTIN_POW_METHODDEF
2680
2677
{"print" , (PyCFunction )builtin_print , METH_FASTCALL | METH_KEYWORDS , print_doc },
2681
2678
BUILTIN_REPR_METHODDEF
2682
- {" round ", (PyCFunction)builtin_round, METH_VARARGS | METH_KEYWORDS, round_doc},
2679
+ BUILTIN_ROUND_METHODDEF
2683
2680
BUILTIN_SETATTR_METHODDEF
2684
2681
BUILTIN_SORTED_METHODDEF
2685
2682
BUILTIN_SUM_METHODDEF
0 commit comments