circuitpython/tests/basics/memoryview_cast.py
2023-05-18 13:26:50 -07:00

22 lines
361 B
Python

try:
memoryview(b'a').cast
except:
print("SKIP")
raise SystemExit
b = bytearray(range(16))
def print_memview(mv):
print(", ".join(hex(v) for v in mv))
mv = memoryview(b)
print_memview(mv)
print_memview(mv[4:])
words = mv.cast("I")
print_memview(words)
print_memview(mv[4:].cast("I"))
print_memview(words[1:])
print_memview(words.cast("B"))