WIP,ENH: Remove np.array fastpaths and move asarray, etc. to C#15270
WIP,ENH: Remove np.array fastpaths and move asarray, etc. to C#15270mattip merged 3 commits intonumpy:mainfrom
np.array fastpaths and move asarray, etc. to C#15270Conversation
np.array fastpaths and move asarray, etc. to Cnp.array fastpaths and move asarray, etc. to C
1f7ce3f to
9b770e8
Compare
9b770e8 to
0d41da7
Compare
0d41da7 to
bd8e89f
Compare
|
Could you modify the top comment for this new version of the PR? It says "The first commit is the new benchmarks, the second is the actual change. The third commit changes ..." Did I miss the benchmarks and the results of running them somewhere? |
|
I posted benchmarks in the initial PR that includes this one. The "benchmarks" this was referring to are the small-array-coercion benchmarks merged more than a year ago :) (this PR is what boosts speeds some up be a factor of 2 – in part underestimating the real factor of probably ~4) Seems PyPy likes it now 🚀 |
This is a fast argument parser (an original version also supported dictionary unpacking (for args, kwargs call style) which supports the new FASTCALL and VECTORCALL convention of CPython. Fastcall is supported by all Python versions we support. This allows todrastically reduces the overhead of methods when keyword arguments are passed.
bd8e89f to
4d8fe21
Compare
Array methods are the easiest target for the new parser. They do not require any larger improvements and most functions in multiarray are wrapped. Similarly the printing functions are not dispatched through `__array_function__` and thus have the most to gain.
4d8fe21 to
9a45332
Compare
|
Arrg, did I end up picking the wrong commit range here? It seems the actual |
This simplifies the code (although it adds the complexity of moving
some of the code to C). It also enables
METH_FASTCALLwhenavailable 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_FASTCALLis not given. IfMETH_FASTCALLis 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.asarrayand 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