# Create a bytearray with some data
data = bytearray(b”Hello, World!”)
# Create a memoryview on the bytearray
view = memoryview(data)
# Access the data directly using the memoryview (no copying)
print(“Original data:”, view.tobytes()) # Print original data as bytes
# Modify the data through the memoryview
view[7:12] = b”Python”
# Check how the changes are reflected in the original data
print(“Modified data:”, data)
# Show that no copying occurred
print(f”Memoryview object: {view}”)