@@ -997,14 +997,14 @@ math_1_to_int(PyObject *arg, double (*func) (double), int can_overflow)
997
997
}
998
998
999
999
static PyObject *
1000
- math_2 (PyObject * args , double (* func ) (double , double ), const char * funcname )
1000
+ math_2 (PyObject * const * args , Py_ssize_t nargs ,
1001
+ double (* func ) (double , double ), const char * funcname )
1001
1002
{
1002
- PyObject * ox , * oy ;
1003
1003
double x , y , r ;
1004
- if (! PyArg_UnpackTuple ( args , funcname , 2 , 2 , & ox , & oy ))
1004
+ if (!_PyArg_CheckPositional ( funcname , nargs , 2 , 2 ))
1005
1005
return NULL ;
1006
- x = PyFloat_AsDouble (ox );
1007
- y = PyFloat_AsDouble (oy );
1006
+ x = PyFloat_AsDouble (args [ 0 ] );
1007
+ y = PyFloat_AsDouble (args [ 1 ] );
1008
1008
if ((x == -1.0 || y == -1.0 ) && PyErr_Occurred ())
1009
1009
return NULL ;
1010
1010
errno = 0 ;
@@ -1042,8 +1042,8 @@ math_2(PyObject *args, double (*func) (double, double), const char *funcname)
1042
1042
PyDoc_STRVAR(math_##funcname##_doc, docstring);
1043
1043
1044
1044
#define FUNC2 (funcname , func , docstring ) \
1045
- static PyObject * math_##funcname(PyObject *self, PyObject *args) { \
1046
- return math_2(args, func, #funcname); \
1045
+ static PyObject * math_##funcname(PyObject *self, PyObject *const * args, Py_ssize_t nargs ) { \
1046
+ return math_2(args, nargs, func, #funcname); \
1047
1047
}\
1048
1048
PyDoc_STRVAR(math_##funcname##_doc, docstring);
1049
1049
@@ -2181,25 +2181,24 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q)
2181
2181
2182
2182
/* AC: cannot convert yet, waiting for *args support */
2183
2183
static PyObject *
2184
- math_hypot (PyObject * self , PyObject * args )
2184
+ math_hypot (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
2185
2185
{
2186
- Py_ssize_t i , n ;
2186
+ Py_ssize_t i ;
2187
2187
PyObject * item ;
2188
2188
double max = 0.0 ;
2189
2189
double x , result ;
2190
2190
int found_nan = 0 ;
2191
2191
double coord_on_stack [NUM_STACK_ELEMS ];
2192
2192
double * coordinates = coord_on_stack ;
2193
2193
2194
- n = PyTuple_GET_SIZE (args );
2195
- if (n > NUM_STACK_ELEMS ) {
2196
- coordinates = (double * ) PyObject_Malloc (n * sizeof (double ));
2194
+ if (nargs > NUM_STACK_ELEMS ) {
2195
+ coordinates = (double * ) PyObject_Malloc (nargs * sizeof (double ));
2197
2196
if (coordinates == NULL ) {
2198
2197
return PyErr_NoMemory ();
2199
2198
}
2200
2199
}
2201
- for (i = 0 ; i < n ; i ++ ) {
2202
- item = PyTuple_GET_ITEM ( args , i ) ;
2200
+ for (i = 0 ; i < nargs ; i ++ ) {
2201
+ item = args [ i ] ;
2203
2202
if (PyFloat_CheckExact (item )) {
2204
2203
x = PyFloat_AS_DOUBLE (item );
2205
2204
} else {
@@ -2215,7 +2214,7 @@ math_hypot(PyObject *self, PyObject *args)
2215
2214
max = x ;
2216
2215
}
2217
2216
}
2218
- result = vector_norm (n , coordinates , max , found_nan );
2217
+ result = vector_norm (nargs , coordinates , max , found_nan );
2219
2218
if (coordinates != coord_on_stack ) {
2220
2219
PyObject_Free (coordinates );
2221
2220
}
@@ -2497,10 +2496,10 @@ static PyMethodDef math_methods[] = {
2497
2496
{"asin" , math_asin , METH_O , math_asin_doc },
2498
2497
{"asinh" , math_asinh , METH_O , math_asinh_doc },
2499
2498
{"atan" , math_atan , METH_O , math_atan_doc },
2500
- {"atan2" , math_atan2 , METH_VARARGS , math_atan2_doc },
2499
+ {"atan2" , ( PyCFunction )( void ( * )( void )) math_atan2 , METH_FASTCALL , math_atan2_doc },
2501
2500
{"atanh" , math_atanh , METH_O , math_atanh_doc },
2502
2501
MATH_CEIL_METHODDEF
2503
- {"copysign" , math_copysign , METH_VARARGS , math_copysign_doc },
2502
+ {"copysign" , ( PyCFunction )( void ( * )( void )) math_copysign , METH_FASTCALL , math_copysign_doc },
2504
2503
{"cos" , math_cos , METH_O , math_cos_doc },
2505
2504
{"cosh" , math_cosh , METH_O , math_cosh_doc },
2506
2505
MATH_DEGREES_METHODDEF
@@ -2517,7 +2516,7 @@ static PyMethodDef math_methods[] = {
2517
2516
MATH_FSUM_METHODDEF
2518
2517
{"gamma" , math_gamma , METH_O , math_gamma_doc },
2519
2518
MATH_GCD_METHODDEF
2520
- {"hypot" , math_hypot , METH_VARARGS , math_hypot_doc },
2519
+ {"hypot" , ( PyCFunction )( void ( * )( void )) math_hypot , METH_FASTCALL , math_hypot_doc },
2521
2520
MATH_ISCLOSE_METHODDEF
2522
2521
MATH_ISFINITE_METHODDEF
2523
2522
MATH_ISINF_METHODDEF
@@ -2531,7 +2530,7 @@ static PyMethodDef math_methods[] = {
2531
2530
MATH_MODF_METHODDEF
2532
2531
MATH_POW_METHODDEF
2533
2532
MATH_RADIANS_METHODDEF
2534
- {"remainder" , math_remainder , METH_VARARGS , math_remainder_doc },
2533
+ {"remainder" , ( PyCFunction )( void ( * )( void )) math_remainder , METH_FASTCALL , math_remainder_doc },
2535
2534
{"sin" , math_sin , METH_O , math_sin_doc },
2536
2535
{"sinh" , math_sinh , METH_O , math_sinh_doc },
2537
2536
{"sqrt" , math_sqrt , METH_O , math_sqrt_doc },
0 commit comments