mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 21:11:12 +02:00
As suggested by @dpgeorge, factor out part of array_construct to allow it to be used for construction & extension. Note that extending with a known-length list (or tuple) goes through the slow path of calling array_extend once per element. Fixes issue #7408. Signed-off-by: Jeff Epler <jepler@gmail.com>
23 lines
327 B
Python
23 lines
327 B
Python
# test array + array
|
|
try:
|
|
import array
|
|
except ImportError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
a1 = array.array('I', [1])
|
|
a2 = array.array('I', [2])
|
|
print(a1 + a2)
|
|
|
|
a1 += array.array('I', [3, 4])
|
|
print(a1)
|
|
|
|
a1.extend(array.array('I', [5]))
|
|
print(a1)
|
|
|
|
a1.extend([6, 7])
|
|
print(a1)
|
|
|
|
a1.extend(i for i in (8, 9))
|
|
print(a1)
|