# create a bytearray
byte_array = bytearray('XYZ', 'utf-8')
print(type(byte_array), byte_array) # 'bytearray' bytearray(b'XYZ')
# craete a memoryview of byte_array
v = memoryview(byte_array)
v[2] = 74 # directly change it without copy
print(byte_array) # bytearray(b'XYJ')
print(byte_array.decode('utf-8')) # XYJ