About 4,580,000 results
Open links in new tab
  1. python - efficient circular buffer? - Stack Overflow

    Mar 16, 2016 · I want to create an efficient circular buffer in python (with the goal of taking averages of the integer values in the buffer). Is this an efficient way to use a list to collect …

  2. python - Clear all items from the queue - Stack Overflow

    If you read the documentation, it refers you to the Queue module's latest source, and there you could see the that the internal representation of a FIFO queue is a deque. In the …

  3. python - queue.Queue vs. collections.deque - Stack Overflow

    Python has at least two queue classes, queue.Queue and collections.deque, with the former seemingly using the latter internally. Both claim to be thread-safe in the documentation.

  4. python - How to slice a deque? - Stack Overflow

    Apr 4, 2012 · deque_slice = collections.deque(itertools.islice(my_deque, 10, 20)) Indexing into a deque requires following a linked list from the beginning each time, so the islice() approach, …

  5. Iterate over deque in python - Stack Overflow

    Since a deque is a doubly linked list, I should be able to iterate through it in order without any performance cost compared to a list. However, the following will be much slower than iterating …

  6. python - How to check if a deque is empty - Stack Overflow

    Apr 13, 2011 · How to check if a deque is empty Asked 14 years, 8 months ago Modified 4 years, 2 months ago Viewed 108k times

  7. How to peek front of deque without popping? - Stack Overflow

    Feb 6, 2018 · Deque too can be interpreted as a list in terms of accessing using indices. You can peek front element by using deque[0] and peek last using deque[-1] This works without …

  8. python - collections.deque get index of element by value - Stack …

    May 1, 2016 · For list we can get index of element list_name.index (3) How to get index of item in deque. ex: d_list = deque ( [1, 2, 3, 4]) what is the best way to get the index of element 3.

  9. python - deque.popleft () and list.pop (0). Is there performance ...

    Sep 13, 2015 · deque.popleft() and list.pop(0) seem to return the same result. Is there any performance difference between them and why?

  10. python - Rolling or sliding window iterator? - Stack Overflow

    Getting collections.deque -like O (1) inserts with array-like O (1) lookups isn't too hard using a circular array--- store the window in a array, but keep a 'head' index that points to the front of …