Python memoryview() Function
The python memoryview() function returns a memoryview object of the given argument.
Python memoryview () Function Example
#A random bytearray
randomByteArray = bytearray('ABC', 'utf-8')
mv = memoryview(randomByteArray)
# access the memory view's zeroth index
print(mv[0])
# It create byte from memory view
print(bytes(mv[0:2]))
# It create list from memory view
print(list(mv[0:3]))
Output:
65
b'AB'
[65, 66, 67]