API: Bump NPY_MAXDIMS to 64 and NPY_MAXARGS to 128 #24072
Closed
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.
Both come up often enough, there was once a PR to bump
NPY_MAXARGS
to 256, but right now I thought, maybe try this and someone else can bump it more ;). (of course bumping requires a major release, though).This increases stack usage and the size of some objects (mainly iterators) of course, otherwise I don't really expect much of an impact, there are a couple of places where this type of arrays are fully zeroed out, but even the worst case should be a very small (few percent) slowdown.
Effect:
NPY_MAXDIMS
in a struct in their headers. This would be problematic if their downstream compiles with NumPy 1.x still.I think it is realistic that this does nothing except bumping the stack use a bit, although I guess it is not unlikely that some downstream libs may not support 64 dims right away.
(I wouldn't mind adjusting some of the places where these are used to use
alloca
, e.g. in ufuncs we almost always have 2, but always have huge working stack area).The discussion then suggested 256, and this was the old PR: #4840
I am not sure, for MAXDIMs, removing the limit entirely is hard, for MAXARGS, it seems like much more to do than back in the day, but at least for the iterator probably not so bad. I.e. it would be nice to not have MAXARGS at all (or maybe have it, but only to switch between stack allocation and malloc.
Until then, does just bumping seem good, should we go with 256. I honestly have no opinion, I did this first remembering it was higher, then saw they suggested 256...