diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2019-09-06 20:54:23 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2019-11-01 17:02:09 +0100 |
commit | 010b6c45912d18e585294df5710a77a2821196db (patch) | |
tree | fde3b9fbfa0f474dfcd87cf2f319c1f7caa3b753 | |
parent | dca26bb439a33c1e072566d78191e9d99b0c34b1 (diff) | |
download | cython-010b6c45912d18e585294df5710a77a2821196db.tar.gz |
Modernise and simplify some code in MemoryView.pyx.
-rw-r--r-- | Cython/Utility/MemoryView.pyx | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Cython/Utility/MemoryView.pyx b/Cython/Utility/MemoryView.pyx index 279e05e63..3c92d5db9 100644 --- a/Cython/Utility/MemoryView.pyx +++ b/Cython/Utility/MemoryView.pyx @@ -1176,11 +1176,10 @@ cdef void copy_strided_to_strided({{memviewslice_name}} *src, @cname('__pyx_memoryview_slice_get_size') cdef Py_ssize_t slice_get_size({{memviewslice_name}} *src, int ndim) nogil: "Return the size of the memory occupied by the slice in number of bytes" - cdef int i - cdef Py_ssize_t size = src.memview.view.itemsize + cdef Py_ssize_t shape, size = src.memview.view.itemsize - for i in range(ndim): - size *= src.shape[i] + for shape in src.shape[:ndim]: + size *= shape return size @@ -1197,11 +1196,11 @@ cdef Py_ssize_t fill_contig_strides_array( if order == 'F': for idx in range(ndim): strides[idx] = stride - stride = stride * shape[idx] + stride *= shape[idx] else: for idx in range(ndim - 1, -1, -1): strides[idx] = stride - stride = stride * shape[idx] + stride *= shape[idx] return stride |