Commit 9d7873cd authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Moved a fourth piece of code from array.rst to the example directory for testing.

parent ff577a2b
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)
...@@ -78,16 +78,7 @@ it is possible to create a new array with the same type as a template, ...@@ -78,16 +78,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 and preallocate a given number of elements. The array is initialized to
zero when requested. zero when requested.
:: .. literalinclude:: ../../examples/tutorial/array/clone.pyx
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)
An array can also be extended and resized; this avoids repeated memory An array can also be extended and resized; this avoids repeated memory
reallocation which would occur if elements would be appended or removed 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