WIP,ENH: Remove np.array
fastpaths and move asarray, etc. to C
#15270
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This simplifies the code (although it adds the complexity of moving
some of the code to C). It also enables
METH_FASTCALL
whenavailable on python (which it is in most relevant versions by now)
Note that as of now, the old fastpaths were faster sometimes faster
if
METH_FASTCALL
is not given. IfMETH_FASTCALL
is used(available on 3.6+, although not official on 3.6) the new version
should always outperform the old one, by a large margin.
The first two commits are the basic infrastructure and simple examples and part of gh-15269. The last commit combines all changes related to moving
np.asarray
and friends to see, removing all special handling.This requires some changes to the
__array_function__
code (with thelike=
argument) unfortunately. It does also replace somenp.array()
usages, which I assumed were often micro-optimization since it was faster to usenp.array()
thannp.asanyarray()
.Forgot to mark as Draft: This includes changes from gh-15269