Explanation:
๐น Step 1: Create Bytes Object
b"abc"
This is a bytes object.
Internally:
a → 97
b → 98
c → 99
(Bytes store ASCII integer values)
๐น Step 2: Create memoryview
x = memoryview(b"abc")
๐งฉ What memoryview Does
memoryview allows direct access to binary data
without copying it.
So:
x
becomes a memory view of:
b"abc"
๐น Step 3: Access Index 1
x[1]
Index positions:
0 → a
1 → b
2 → c
At index 1:
b
BUT ⚠️
For memoryview of bytes:
Python returns INTEGER byte value,
NOT character.
ASCII of:
b → 98
So:
x[1] → 98
๐น Step 4: Print Result
print(98)
๐ Final Output:
98

0 Comments:
Post a Comment