summaryrefslogtreecommitdiff
path: root/docs/examples/tutorial/array/unsafe_usage.py
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/tutorial/array/unsafe_usage.py')
-rw-r--r--docs/examples/tutorial/array/unsafe_usage.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/examples/tutorial/array/unsafe_usage.py b/docs/examples/tutorial/array/unsafe_usage.py
new file mode 100644
index 000000000..99b2b1690
--- /dev/null
+++ b/docs/examples/tutorial/array/unsafe_usage.py
@@ -0,0 +1,11 @@
+from cython.cimports.cpython import array
+import array
+
+a = cython.declare(array.array, array.array('i', [1, 2, 3]))
+
+# access underlying pointer:
+print(a.data.as_ints[0])
+
+from cython.cimports.libc.string import memset
+
+memset(a.data.as_voidptr, 0, len(a) * cython.sizeof(cython.int))