0

deque
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

deque

by bludin on Sun Jan 10, 2021 6:19 pm

does cp offer a type similar to collections.deque?

bludin
 
Posts: 40
Joined: Thu Apr 16, 2020 8:57 am

Re: deque

by dastels on Sun Jan 10, 2021 6:45 pm

You can use a List with:
- pop() to remove from the tail
- append(x) to add to the tail
- pop(0) to remove from the head
- insert(0, x) to add to the head

Dave

dastels
 
Posts: 4850
Joined: Tue Oct 20, 2015 3:22 pm

Re: deque

by tannewt on Mon Jan 11, 2021 7:04 pm

Looks like the code we inherited from MicroPython has it but it's disabled. The config for it is MICROPY_PY_COLLECTIONS_DEQUE and it's only enabled in the unix port.

tannewt
 
Posts: 2034
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.