summaryrefslogtreecommitdiff
path: root/numpy/lib/arraypad.py
diff options
context:
space:
mode:
authorJonathan L Long <jonlong@cs.berkeley.edu>2013-12-17 16:24:07 -0800
committerJonathan L Long <jonlong@cs.berkeley.edu>2013-12-17 16:33:31 -0800
commitcf22b319191c47b66d6a690888cb16ba0e08c122 (patch)
tree807ca7435ea1de4210897888ee05badb8edca96b /numpy/lib/arraypad.py
parentff325bb2a3e06355051bb044b6047907027105d5 (diff)
downloadnumpy-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.
Diffstat (limited to 'numpy/lib/arraypad.py')
-rw-r--r--numpy/lib/arraypad.py2
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