89DEVs

Python memoryview() function

overview of memoryview()

The memoryview() function returns a memory view object of the given object. It allows Python to access internal buffers of the object.

use of memoryview()

To access the memory view object of a given byte or bytearray, use the memoryview() function as shown below. # use of memoryview mv = memoryview(b"Python") print(mv) The memoryview object of the byte value is printed. <memory at 0x10beca7c0>

syntax of memoryview()

The syntax of the memoryview() function is: memoryview(obj)

arguments of memoryview()

The memoryview() function accepts a single parameter, which is required. The argument is the object, which internal data will be revealed. The object must also support the buffer protocol for example bytes or bytearray.

return values of memoryview()

The memoryview() function returns a memory view object of the given object.

                
        

Summary


Click to jump to section