memoryview()
Built-in FunctionPython 2.7+Advanced
Creates a memory view object for binary data without copying
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.7+
Learn by Difficulty
Quick Example
python
data = bytearray(b"hello") mv = memoryview(data) print(mv[0]) print(bytes(mv[1:3]))
memoryview() is a built-in function that creates a memory view object for binary data without copying.
Try in PlaygroundTags
builtinfunctioncoredatatypebinarybufferperformance
Related Items
bytes()
Built-in Function
Creates an immutable sequence of bytes
bytearray()
Built-in Function
Creates a mutable sequence of bytes
struct
Stdlib — Data
Pack and unpack binary data (C-style structs) to/from bytes
array
Stdlib — Data
Efficient arrays of numeric values; more compact than lists
numpy
Package — Data Science
N-dimensional arrays, vectorized math, linear algebra, FFT