summaryrefslogtreecommitdiff
path: root/tests/micropython/heapalloc_slice.py
blob: 62d96595c719e35fe270b5ad4e5cf0665e7d4140 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# slice operations that don't require allocation
try:
    from micropython import heap_lock, heap_unlock
except (ImportError, AttributeError):
    heap_lock = heap_unlock = lambda: 0

b = bytearray(range(10))

m = memoryview(b)

heap_lock()

b[3:5] = b"aa"
m[5:7] = b"bb"

heap_unlock()

print(b)