From 172a1942893b5ce55abccd836fdd9f00235a6767 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Mon, 23 Jan 2023 18:58:02 +0100 Subject: ENH: Convert methods to vectorcall conversions (#23018) Convert several methods to the vectorcall convention. The conversions give a performance improvement, see #20790 (comment) Some notes: * For vdot the METH_KEYWORDS was removed, as the C vdot method was positional only. * The add_docstring is converted with an additional check. It was parsed as if (!PyArg_ParseTuple(args, "OO!:add_docstring", &obj, &PyUnicode_Type, &str)), but there is no support for the ! in the npy_parse_arguments * CI was complaining about coverage of _get_ndarray_c_version. A test was added, but only to provide coverage * In function_base.py a redundant check in def place was removed Co-authored-by: Sebastian Berg --- numpy/core/multiarray.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index efb504240..ec1294b85 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -14,7 +14,7 @@ from ._multiarray_umath import * # noqa: F403 # do not change them. issue gh-15518 # _get_ndarray_c_version is semi-public, on purpose not added to __all__ from ._multiarray_umath import ( - fastCopyAndTranspose, _flagdict, from_dlpack, _insert, _reconstruct, + fastCopyAndTranspose, _flagdict, from_dlpack, _place, _reconstruct, _vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version, _get_madvise_hugepage, _set_madvise_hugepage, _get_promotion_state, _set_promotion_state, @@ -25,7 +25,7 @@ __all__ = [ 'ITEM_HASOBJECT', 'ITEM_IS_POINTER', 'LIST_PICKLE', 'MAXDIMS', 'MAY_SHARE_BOUNDS', 'MAY_SHARE_EXACT', 'NEEDS_INIT', 'NEEDS_PYAPI', 'RAISE', 'USE_GETITEM', 'USE_SETITEM', 'WRAP', - '_flagdict', 'from_dlpack', '_insert', '_reconstruct', '_vec_string', + '_flagdict', 'from_dlpack', '_place', '_reconstruct', '_vec_string', '_monotonicity', 'add_docstring', 'arange', 'array', 'asarray', 'asanyarray', 'ascontiguousarray', 'asfortranarray', 'bincount', 'broadcast', 'busday_count', 'busday_offset', 'busdaycalendar', 'can_cast', @@ -1128,7 +1128,7 @@ def copyto(dst, src, casting=None, where=None): @array_function_from_c_func_and_dispatcher(_multiarray_umath.putmask) -def putmask(a, mask, values): +def putmask(a, /, mask, values): """ putmask(a, mask, values) -- cgit v1.2.1