Skip to content

Commit c7d8696

Browse files
author
Luke Shaw
committed
Reduce memory requirements when no need to copy result
1 parent 6612cdb commit c7d8696

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/blosc2/lazyexpr.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,6 @@ def slices_eval_getitem(
16631663
ne_args = {}
16641664
where: dict | None = kwargs.pop("_where_args", None)
16651665

1666-
dtype = kwargs.pop("dtype", None)
16671666
if out is None:
16681667
# Compute the shape and chunks of the output array, including broadcasting
16691668
shape = compute_broadcast_shape(operands.values())
@@ -1700,11 +1699,11 @@ def slices_eval_getitem(
17001699
new_expr = f"where({expression}, _where_x, _where_y)"
17011700
result = ne_evaluate(new_expr, slice_operands, **ne_args)
17021701

1703-
if out is None:
1704-
out = np.empty(shape=result.shape, dtype=dtype)
1705-
out[()] = result
1706-
1707-
return out
1702+
if out is None: # avoid copying unnecessarily
1703+
return result
1704+
else:
1705+
out[()] = result
1706+
return out
17081707

17091708

17101709
def infer_reduction_dtype(dtype, operation):

0 commit comments

Comments
 (0)