Python built-in function memoryview (obj) usage, pythonmemoryview
The memoryview () function returns the memory view object (Momory view) of the given parameter ).
Syntax
Memoryview Syntax: memoryview (obj)
Parameter description: obj -- Object
Returned value: returns the list of tuples.
English document:
Class memoryview (obj)
Memoryview objects allow Python code to access the internal data of an object that supports the buffer protocol without copying.
Create a memoryview that references obj. obj must support the buffer protocol. Built-in objects that support the buffer protocol include bytes and bytearray.
Note:
1. The function returns the memory view object, which is actually the constructor of the memory view object (Momory view.
2. The so-called memory viewing object refers to packaging data that supports the buffer protocol and allowing Python code access without copying objects.
3. Python built-in objects that support the buffer protocol include bytes and bytearray.
Example
>>> v = memoryview(b'abcefg')>>> v[1]98>>> v[-1]103>>> v[1:4]<memory at 0x7f3ddc9f4350>>>> bytes(v[1:4])b'bce'
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.