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

Merge pull request #2348 from gabrieldemarmiesse/test_working_with_python_arrays_5

Adding tests for "working with python arrays" part 5
parents e8bd642c f780ba4c
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))
...@@ -61,18 +61,7 @@ An array can also be extended and resized; this avoids repeated memory ...@@ -61,18 +61,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