class Ringbuffer(object): def __init__(self, size): self.data = [False]*size self._cursor = 0 def insert(self, item): self.data[self._cursor] = item self._cursor = (self._cursor + 1) % len(self.data) def has(self, item): return item in self.data