diff options
author | Pieter Eendebak <pieter.eendebak@gmail.com> | 2022-05-11 10:02:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-11 10:02:54 +0200 |
commit | 79875572916a5c8805cb7bdd00a5b26df72b0733 (patch) | |
tree | 75a20e87afb51c35e5a0f26f98590879829d9098 /numpy/array_api/_indexing_functions.py | |
parent | c360f1ebb09cca42c32f715aa2b730ef9874fde4 (diff) | |
download | numpy-79875572916a5c8805cb7bdd00a5b26df72b0733.tar.gz |
PERF: Skip probing `__array_ufunc__` for NumPy builtin scalars (#21470)
The method `PyUFuncOverride_GetNonDefaultArrayUfunc` is expensive on numpy scalars because these objects do not have a `__array_ufunc__` set and for a missing attribute lookup cpython generates an exception that is later cleared by numpy. This is a performance bottleneck, see #21455.
An issue has been submitted to cpython (https://github.com/python/cpython/issues/92216). But even if this is addressed in cpython, it will take untill python 3.12+ before this will be useable by numpy.
As an alternative solution, this PR adds a fast path to `PyUFuncOverride_GetNonDefaultArrayUfunc` to determine whether an object is a numpy scalar.
Diffstat (limited to 'numpy/array_api/_indexing_functions.py')
0 files changed, 0 insertions, 0 deletions