summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/memoryview_gc.py
blob: a1e4baad479ba15585712d3b5dbda7c1429a33f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# test memoryview retains pointer to original object/buffer

b = bytearray(10)
m = memoryview(b)[1:]
for i in range(len(m)):
    m[i] = i

# reclaim b, but hopefully not the buffer
b = None
import gc
gc.collect()

# allocate lots of memory
for i in range(100000):
    [42, 42, 42, 42]

# check that the memoryview is still what we want
print(list(m))