← index #5244PR #440
Related · medium · value 0.308
QUERY · ISSUE

collections.deque constructor does not take keyword arguments

openby nevercastopened 2019-10-21updated 2019-11-15
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

closedby mattytrentiniopened 2021-08-21updated 2024-03-18

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.

5 comments
BrianPugh · 2023-05-10

chiming in that this helped make some of my cpython code be micropython-compatible.

mattytrentini · 2024-03-18

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!

dpgeorge · 2024-03-18

Now that the core collections.deque class is more fully implemented, I think we should just remove the deque implementation here. That will prevent any confusion, everyone will just use the built-in version.

mattytrentini · 2024-03-18

I agree; the differences are minimal, so I'll close this. Fantastic to see the built-in deque improved!

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied