summaryrefslogtreecommitdiff
path: root/numpy/array_api/_elementwise_functions.py
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2022-05-17 13:04:23 +0300
committerGitHub <noreply@github.com>2022-05-17 12:04:23 +0200
commitdd5ab7b11520cf9cfa2129303c02ff30b2960d6f (patch)
treee6a320a8d4c11818154312e9a03d50f444958770 /numpy/array_api/_elementwise_functions.py
parentc5a999682bf94cfd08cc64b49efef38371cbdb2e (diff)
downloadnumpy-dd5ab7b11520cf9cfa2129303c02ff30b2960d6f.tar.gz
MAINT: Reduce allocation size of empty (0 size) arrays to 1 byte (#21477)
* MAINT: Shrink the size of memory allocations to 1 bytes for arrays with `size == 0`. In order to avoid undefined behavior, we need to ensure the generated strides are all zero. * if any dims is 0, allocate array of length 1 * fix from review: make sure all strides are 0 when nbytes is 0 * fixes from review, fixes to assumptions about strides * from review, unconditionally set the stride * BUG: Fix FromIter stride resetting logic We have to reset all strides in the case of a subarray dtype which may have caused the result array to not be 1-D. Since the logic is a bit complicated now, restore the logic to only do this when it really is necessary. * MAINT: Remove now unnecessary `PyArray_NBYTES_ALLOCATED` helper * ENH: short-cut trivial ufunc loops when array.size == 0 * BUG: ensure view of non-empty array with strides == (0,) raises Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
Diffstat (limited to 'numpy/array_api/_elementwise_functions.py')
0 files changed, 0 insertions, 0 deletions