Commit e3e545ec authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2346 from gabrieldemarmiesse/test_working_with_python_arrays_3

Adding tests for "working with python arrays" part 3
parents 68ba1ef0 ba47bbdd
from cpython cimport array
import array
cdef array.array a = array.array('i', [1, 2, 3])
# access underlying pointer:
print(a.data.as_ints[0])
from libc.string cimport memset
memset(a.data.as_voidptr, 0, len(a) * sizeof(int))
......@@ -42,18 +42,7 @@ functions, it is possible to access the underlying contiguous array as a
pointer. There is no type or bounds checking, so be careful to use the
right type and signedness.
::
from cpython cimport array
import array
cdef array.array a = array.array('i', [1, 2, 3])
# access underlying pointer:
print(a.data.as_ints[0])
from libc.string cimport memset
memset(a.data.as_voidptr, 0, len(a) * sizeof(int))
.. literalinclude:: ../../examples/tutorial/array/unsafe_usage.pyx
Note that any length-changing operation on the array object may invalidate the
pointer.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment