How to get the size of typed memoryviews in cython
Asked Answered
S

1

9

Is it possible to get the size of a MemoryView in cython? Ideally, I'm looking for something like arr.shape in numpy.

Stefanistefania answered 5/12, 2013 at 14:37 Comment(0)
R
10

From http://docs.python.org/3.3/library/stdtypes.html#memoryview

len(view) is equal to the length of tolist. If view.ndim = 0, the length is 1. If view.ndim = 1, the length is equal to the number of elements in the view. For higher dimensions, the length is equal to the length of the nested list representation of the view. The itemsize attribute will give you the number of bytes in a single element.

Rattish answered 5/12, 2013 at 15:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.