Staging: this is not the live site, pydocs.org.
Create a new memoryview object which references the given object.
Changed in 3.3, 3.4, 3.5, 3.12, 3.14
- 3.3: One-dimensional memoryviews can now be sliced. One-dimensional memoryviews with formats ‘B’, ‘b’ or ‘c’ are now hashable.
- 3.4: memoryview is now registered automatically with collections.abc.Sequence
- 3.5: memoryviews can now be indexed with a tuple of integers.
- 3.12: If view.ndim == 0, len(view) now raises TypeError instead of returning 1.
- 3.14: memoryview is now a generic type.
Members of memoryview
c
- c_contiguous
- A bool indicating whether the memory is C contiguous.
- cast
- Cast a memoryview to a new format or shape.
- contiguous
- A bool indicating whether the memory is contiguous.
- count
- Count the number of occurrences of a value.
f
- f_contiguous
- A bool indicating whether the memory is Fortran contiguous.
- format
- A string containing the format (in struct module style) for each element in the view.
h
- hex
- Return the data in the buffer as a str of hexadecimal numbers.
i
- index
- Return the index of the first occurrence of a value.
- itemsize
- The size in bytes of each element of the memoryview.
n
- nbytes
- The amount of space in bytes that the array would use in a contiguous representation.
- ndim
- An integer indicating how many dimensions of a multi-dimensional array the memory represents.
o
- obj
- The underlying object of the memoryview.
r
- readonly
- A bool indicating whether the memory is read only.
- release
- Release the underlying buffer exposed by the memoryview object.
s
- shape
- A tuple of ndim integers giving the shape of the memory as an N-dimensional array.
- strides
- A tuple of ndim integers giving the size in bytes to access each element for each dimension of the array.
- suboffsets
- A tuple of integers used internally for PIL-style arrays.
t
- tobytes
- Return the data in the buffer as a byte string.
- tolist
- Return the data in the buffer as a list of elements.
- toreadonly
- Return a readonly version of the memoryview.