efficient circular buffer?

I would use collections.deque with a maxlen arg >>> import collections >>> d = collections.deque(maxlen=10) >>> d deque([], maxlen=10) >>> for i in xrange(20): … d.append(i) … >>> d deque([10, 11, 12, 13, 14, 15, 16, 17, 18, 19], maxlen=10) There is a recipe in the docs for deque that is similar to what you … Read more