diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2021-12-07 20:17:17 -0600 |
---|---|---|
committer | Sebastian Berg <sebastianb@nvidia.com> | 2023-01-17 18:40:44 +0100 |
commit | 60a858a372b14b73547baacf4a472eccfade1073 (patch) | |
tree | 1061a985383ad6ab2a8dc56f144ec25cfbff071e /numpy/array_api/_constants.py | |
parent | 9b6a7b4f874f5502112f36d485b12d92889eb808 (diff) | |
download | numpy-60a858a372b14b73547baacf4a472eccfade1073.tar.gz |
ENH: Improve array function overhead by using vectorcall
This moves dispatching for `__array_function__` into a C-wrapper. This
helps speed for multiple reasons:
* Avoids one additional dispatching function call to C
* Avoids the use of `*args, **kwargs` which is slower.
* For simple NumPy calls we can stay in the faster "vectorcall" world
This speeds up things generally a little, but can speed things up a lot
when keyword arguments are used on lightweight functions, for example::
np.can_cast(arr, dtype, casting="same_kind")
is more than twice as fast with this.
There is one alternative in principle to get best speed: We could inline
the "relevant argument"/dispatcher extraction. That changes behavior in
an acceptable but larger way (passes default arguments).
Unless the C-entry point seems unwanted, this should be a decent step
in the right direction even if we want to do that eventually, though.
Closes gh-20790
Closes gh-18547 (although not quite sure why)
Diffstat (limited to 'numpy/array_api/_constants.py')
0 files changed, 0 insertions, 0 deletions