2014-10-26 13:20:50 +00:00
|
|
|
# test memoryview retains pointer to original object/buffer
|
2017-02-15 15:11:16 +00:00
|
|
|
try:
|
|
|
|
memoryview
|
|
|
|
except:
|
|
|
|
print("SKIP")
|
2017-06-10 18:03:01 +01:00
|
|
|
raise SystemExit
|
2014-10-26 13:20:50 +00:00
|
|
|
|
|
|
|
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))
|