Commit f780ba4c authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Moved a fifth piece of code from array.rst to the examples directory.

parent ff577a2b
from cpython cimport array
import array
cdef array.array a = array.array('i', [1, 2, 3])
cdef array.array b = array.array('i', [4, 5, 6])
# extend a with b, resize as needed
array.extend(a, b)
# resize a, leaving just original three elements
array.resize(a, len(a) - len(b))
...@@ -93,18 +93,7 @@ An array can also be extended and resized; this avoids repeated memory ...@@ -93,18 +93,7 @@ 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
one by one. one by one.
:: .. literalinclude:: ../../examples/tutorial/array/resize.pyx
from cpython cimport array
import array
cdef array.array a = array.array('i', [1, 2, 3])
cdef array.array b = array.array('i', [4, 5, 6])
# extend a with b, resize as needed
array.extend(a, b)
# resize a, leaving just original three elements
array.resize(a, len(a) - len(b))
API reference API reference
......
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