mirror of
https://github.com/W3SLAV/micropython.git
synced 2025-06-20 12:35:34 -04:00

Add `pop()`, `appendleft()`, and `extend()` methods, support iteration and indexing, and initializing from an existing sequence. Iteration and indexing (subscription) have independent configuration flags to enable them. They are enabled by default at the same level that collections.deque is enabled (the extra features level). Also add tests for checking new behavior. Signed-off-by: Damien George <damien@micropython.org>
30 lines
507 B
Python
30 lines
507 B
Python
try:
|
|
from collections import deque
|
|
except ImportError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
d = deque((), 10)
|
|
|
|
d.append(1)
|
|
d.append(2)
|
|
d.append(3)
|
|
|
|
# Index slicing for reads is not supported in CPython
|
|
try:
|
|
d[0:1]
|
|
except TypeError:
|
|
print("TypeError")
|
|
|
|
# Index slicing for writes is not supported in CPython
|
|
try:
|
|
d[0:1] = (-1, -2)
|
|
except TypeError:
|
|
print("TypeError")
|
|
|
|
# Index slicing for writes is not supported in CPython
|
|
try:
|
|
del d[0:1]
|
|
except TypeError:
|
|
print("TypeError")
|