-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
WIP,ENH: Remove np.array
fastpaths and move asarray, etc. to C
#15270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP,ENH: Remove np.array
fastpaths and move asarray, etc. to C
#15270
Conversation
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_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