Python built-in function memoryview (obj) usage, pythonmemoryview

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.