25 Sep
2012
25 Sep
'12
11:31 a.m.
On 25.09.2012 11:38, Nathaniel Smith wrote:
Implementing a ring buffer on top of ndarray would be pretty straightforward and probably work better than a linked-list implementation.
Amazingly, many do not know that a ringbuffer is simply an array indexed modulus its length: foo = np.zeros(n) i = 0 while 1: foo[i % n] # access ringbuffer i += 1 Also, instead of writing a linked list, consider collections.deque. A deque is by definition a double-ended queue. It is just waste of time to implement a deque (double-ended queue) and hope it will perform better than Python's standard lib collections.deque object. Sturla