Say I want a container to store some value returned from a sensor at 50Hz. I want store the present value, and also the last 100 so that I can say something about how the value is changing. What kind of container am I looking for? I was thinking maybe deque, and something like this:
def updateValue(data):
self._value.append(data)
self._value.popleft()
So every 20ms updateValue is called and appends an element on the end, and removes one from the start. Is there a more efficient way to do this?