-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
CircuitPython version
Adafruit CircuitPython 9.0.5 on 2024-05-22; Adafruit PyPortal with samd51j20
Code/REPL
from collections import deque
a = deque((), 5)
len(a)
a.append(0)
a.append(1)
a.append(2)
a.append(3)
a.append(4)
len(a)
a[0]
list(a)
Behavior
0
5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'deque' object isn't subscriptable
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'deque' object is not iterable
Description
The circuitpython collection.deque package does not match the functionality described in https://docs.circuitpython.org/en/latest/docs/library/collections.html#collections.deque
Either the documentation is wrong, or deque is broken, at least for the pyportal build.
Additional information
The information in older issues seem to indicate that deque was implemented, including making it iterable, but that is not what I see. I see a few deque references in the Adafruit Learning System Guides repo:
grep -R --include="*.py" 'deque' .
but from my tests only one of them would actually work in this environment. The empty list with limit. Tests show that using a list for the iterable parameter does not work, and neither does specifying the maxlen keyword.
Another search in the circuitpython repo found some references in tests. Again, many would appear to fail from the repl tests I did. The comment in tests/cpydiff/modules_deque.py says "Deque not implemented", which is not accurate either. A hold over from the fork?