Home >>Python Built-in Functions >Python memoryview() Function

Python memoryview() Function

Python memoryview() Function

Python memoryview() function is used to return a memory view object from a given input object. It also allows direct read and write access to an object’s byte-oriented data without copying it.

Syntax:
memoryview(obj)

Parameter Values

Parameter Description
obj This parameter defines a Bytes object or a Bytearray object.
Here is an example of Python memoryview() function:

x = memoryview(b"PHPTPOINT")
print(x)
print(x[0])
print(x[1])

Output:

80
72
Example 2:

x = memoryview(b"PHPTPOINT")
print(x)
print(x[0])
print(x[1])
print(x[2])
print(x[3])
print(x[4])
print(x[5])
print(x[6])
print(x[7])
print(x[8])

Output:
80
72
80
84
80
79
73
78
84

Python Built-in Functions Python abs() Function Python all() Function Python any() Function Python ascii() Function Python bin() Function Python bool() Function Python bytearray() Function Python bytes() Function Python callable() Function Python chr() Function Python compile() Function Python complex() Function Python delattr() Function Python dict() Function Python dir() Function Python divmod() Function Python enumerate() Function Python eval() Function Python exec() Function Python filter() Function Python float() Function Python format() Function Python frozenset() Function Python getattr() Function Python globals() Function Python hasattr() Function Python hash() Function Python help() Function Python hex() Function Python id() Function Python input() Function Python int() Function Python isinstance() Function Python issubclass() Function Python iter() Function Python len() Function Python list() Function Python locals() Function Python map() Function Python max() Function Python memoryview() Function Python min() Function Python next() Function Python object() Function Python oct() Function Python open() Function Python ord() Function Python pow() Function Python print() Function Python property() function Python range() Function Python repr() Function Python reversed() Function Python round() Function Python set() Function Python setattr() Function Python slice() Function Python sorted() Function Python str() Function Python sum() Function Python super() Function Python tuple() Function Python type() Function Python vars() Function Python zip() Function