summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/memoryview_gc.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/basics/memoryview_gc.py b/tests/basics/memoryview_gc.py
new file mode 100644
index 0000000000..a1e4baad47
--- /dev/null
+++ b/tests/basics/memoryview_gc.py
@@ -0,0 +1,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))