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

Merge pull request #2347 from gabrieldemarmiesse/test_working_with_python_arrays_4

Adding tests for "working with python arrays" part 4
parents e3e545ec 9d7873cd
from cpython cimport array
import array
cdef array.array int_array_template = array.array('i', [])
cdef array.array newarray
# create an array with 3 elements with same type as template
newarray = array.clone(int_array_template, 3, zero=False)
......@@ -55,16 +55,7 @@ it is possible to create a new array with the same type as a template,
and preallocate a given number of elements. The array is initialized to
zero when requested.
::
from cpython cimport array
import array
cdef array.array int_array_template = array.array('i', [])
cdef array.array newarray
# create an array with 3 elements with same type as template
newarray = array.clone(int_array_template, 3, zero=False)
.. literalinclude:: ../../examples/tutorial/array/clone.pyx
An array can also be extended and resized; this avoids repeated memory
reallocation which would occur if elements would be appended or removed
......
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