diff options
author | Jonathan L Long <jonlong@cs.berkeley.edu> | 2013-12-17 16:24:07 -0800 |
---|---|---|
committer | Jonathan L Long <jonlong@cs.berkeley.edu> | 2013-12-17 16:33:31 -0800 |
commit | cf22b319191c47b66d6a690888cb16ba0e08c122 (patch) | |
tree | 807ca7435ea1de4210897888ee05badb8edca96b | |
parent | ff325bb2a3e06355051bb044b6047907027105d5 (diff) | |
download | numpy-cf22b319191c47b66d6a690888cb16ba0e08c122.tar.gz |
Avoid overallocating memory in arraypad with user supplied function
Previously, arraypad used zeros(shape).astype(dtype) instead of
zeros(shape, dtype), which could allocate up to eight times more memory
than necessary.
-rw-r--r-- | numpy/lib/arraypad.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/lib/arraypad.py b/numpy/lib/arraypad.py index 32cb4ee1f..82f741df9 100644 --- a/numpy/lib/arraypad.py +++ b/numpy/lib/arraypad.py @@ -1343,7 +1343,7 @@ def pad(array, pad_width, mode=None, **kwargs): pad_width[i][0] + narray.shape[i]) for i in rank] new_shape = np.array(narray.shape) + total_dim_increase - newmat = np.zeros(new_shape).astype(narray.dtype) + newmat = np.zeros(new_shape, narray.dtype) # Insert the original array into the padded array newmat[offset_slices] = narray |