[Numpy-discussion] Double-ended queues

Nathaniel Smith njs at pobox.com
Tue Sep 25 05:38:40 EDT 2012


On Tue, Sep 25, 2012 at 10:03 AM, William Furnass <will at thearete.co.uk> wrote:
> Hi all,
>
> I want to be able to within a loop a) apply a mathematical operation
> to all elements in a vector (can be done atomically) then b) pop zero
> or more elements from one end of the vector and c) push zero or more
> elements on to the other end.  So far I've used a collections.deque to
> store my vector as it should be more efficient than a numpy array for
> the appending and deletion of elements.  However, I was wondering
> whether performance could be improved through the use of a
> homogeneously-typed double-ended queue i.e. a linked list equivalent
> of numpy.ndarray.

Implementing a ring buffer on top of ndarray would be pretty
straightforward and probably work better than a linked-list
implementation.

-n



More information about the NumPy-Discussion mailing list