QUERY · ISSUE
collections.deque constructor does not take keyword arguments
enhancementpy-core
I would like to construct a deque as follows collections.deque(maxlen=10). For this to work, iterables must have a default. The default should be an empty tuple or None, see: https://docs.python.org/3/library/collections.html#collections.deque
maxlen should also support keyword arguments but would not require a default, i.e not optional, since I don't need arbitrarily (unbounded) length deques.
CANDIDATE · PULL REQUEST
WIP: Update deque
MicroPython's built-in deque lacks many features but is implemented in C so is very lean and fast.
The micropython-lib version is implemented in Python and has more features - but should have even more. This is a start toward achieving feature-parity with CPython's deque.
This could possibly be merged as-is (I had to extend deque to supporting porting the progress library to MicroPython) but I'm going to try and add all the other features of deque as well as use as much as possible of the CPython test cases.
chiming in that this helped make some of my cpython code be micropython-compatible.
Note that the built-in deque has had some substantial improvements, see:
https://github.com/micropython/micropython/commit/7dff38fdc190d7b731fad8319d2ae8aa13fde18a
There is little reason to use this Python version now - which is great!
Now that the core
collections.dequeclass is more fully implemented, I think we should just remove thedequeimplementation here. That will prevent any confusion, everyone will just use the built-in version.I agree; the differences are minimal, so I'll close this. Fantastic to see the built-in deque improved!