@@ -4925,65 +4925,6 @@ ufunc_generic_fastcall(PyUFuncObject *ufunc,
49254925}
49264926
49274927
4928- /*
4929- * TODO: The implementation below can be replaced with PyVectorcall_Call
4930- * when available (should be Python 3.8+).
4931- */
4932- static PyObject *
4933- ufunc_generic_call (
4934- PyUFuncObject * ufunc , PyObject * args , PyObject * kwds )
4935- {
4936- Py_ssize_t len_args = PyTuple_GET_SIZE (args );
4937- /*
4938- * Wrapper for tp_call to tp_fastcall, to support both on older versions
4939- * of Python. (and generally simplifying support of both versions in the
4940- * same codebase.
4941- */
4942- if (kwds == NULL ) {
4943- return ufunc_generic_fastcall (ufunc ,
4944- PySequence_Fast_ITEMS (args ), len_args , NULL , NPY_FALSE );
4945- }
4946-
4947- PyObject * new_args [NPY_MAXARGS ];
4948- Py_ssize_t len_kwds = PyDict_Size (kwds );
4949-
4950- if (NPY_UNLIKELY (len_args + len_kwds > NPY_MAXARGS )) {
4951- /*
4952- * We do not have enough scratch-space, so we have to abort;
4953- * In practice this error should not be seen by users.
4954- */
4955- PyErr_Format (PyExc_ValueError ,
4956- "%s() takes from %d to %d positional arguments but "
4957- "%zd were given" ,
4958- ufunc_get_name_cstr (ufunc ) , ufunc -> nin , ufunc -> nargs , len_args );
4959- return NULL ;
4960- }
4961-
4962- /* Copy args into the scratch space */
4963- for (Py_ssize_t i = 0 ; i < len_args ; i ++ ) {
4964- new_args [i ] = PyTuple_GET_ITEM (args , i );
4965- }
4966-
4967- PyObject * kwnames = PyTuple_New (len_kwds );
4968-
4969- PyObject * key , * value ;
4970- Py_ssize_t pos = 0 ;
4971- Py_ssize_t i = 0 ;
4972- while (PyDict_Next (kwds , & pos , & key , & value )) {
4973- Py_INCREF (key );
4974- PyTuple_SET_ITEM (kwnames , i , key );
4975- new_args [i + len_args ] = value ;
4976- i ++ ;
4977- }
4978-
4979- PyObject * res = ufunc_generic_fastcall (ufunc ,
4980- new_args , len_args , kwnames , NPY_FALSE );
4981- Py_DECREF (kwnames );
4982- return res ;
4983- }
4984-
4985-
4986- #if PY_VERSION_HEX >= 0x03080000
49874928/*
49884929 * Implement vectorcallfunc which should be defined with Python 3.8+.
49894930 * In principle this could be backported, but the speed gain seems moderate
@@ -5001,7 +4942,6 @@ ufunc_generic_vectorcall(PyObject *ufunc,
50014942 return ufunc_generic_fastcall ((PyUFuncObject * )ufunc ,
50024943 args , PyVectorcall_NARGS (len_args ), kwnames , NPY_FALSE );
50034944}
5004- #endif /* PY_VERSION_HEX >= 0x03080000 */
50054945
50064946
50074947NPY_NO_EXPORT PyObject *
@@ -5178,11 +5118,7 @@ PyUFunc_FromFuncAndDataAndSignatureAndIdentity(PyUFuncGenericFunction *func, voi
51785118 ufunc -> core_dim_flags = NULL ;
51795119 ufunc -> userloops = NULL ;
51805120 ufunc -> ptr = NULL ;
5181- #if PY_VERSION_HEX >= 0x03080000
51825121 ufunc -> vectorcall = & ufunc_generic_vectorcall ;
5183- #else
5184- ufunc -> reserved2 = NULL ;
5185- #endif
51865122 ufunc -> reserved1 = 0 ;
51875123 ufunc -> iter_flags = 0 ;
51885124
@@ -6437,19 +6373,15 @@ NPY_NO_EXPORT PyTypeObject PyUFunc_Type = {
64376373 .tp_basicsize = sizeof (PyUFuncObject ),
64386374 .tp_dealloc = (destructor )ufunc_dealloc ,
64396375 .tp_repr = (reprfunc )ufunc_repr ,
6440- .tp_call = ( ternaryfunc ) ufunc_generic_call ,
6376+ .tp_call = & PyVectorcall_Call ,
64416377 .tp_str = (reprfunc )ufunc_repr ,
64426378 .tp_flags = Py_TPFLAGS_DEFAULT |
6443- #if PY_VERSION_HEX >= 0x03080000
64446379 _Py_TPFLAGS_HAVE_VECTORCALL |
6445- #endif
64466380 Py_TPFLAGS_HAVE_GC ,
64476381 .tp_traverse = (traverseproc )ufunc_traverse ,
64486382 .tp_methods = ufunc_methods ,
64496383 .tp_getset = ufunc_getset ,
6450- #if PY_VERSION_HEX >= 0x03080000
64516384 .tp_vectorcall_offset = offsetof(PyUFuncObject , vectorcall ),
6452- #endif
64536385};
64546386
64556387/* End of code for ufunc objects */
0 commit comments