title: Fast Circular buffer in python than the one using deque?
body: <p>I am implementing circular buffer in python using collections.deque to use it for some calculations. This is my original code:</p>
  
  <pre><code>clip=moviepy.editor.VideoFileClip('file.mp4')
  clip_size= clip.size[::-1]
  Depth=30
  dc=5
  TempKern = # some array of size Depth
  RingBuffer=deque(np.zeros(clip_size, dtype=float),maxlen=NewDepth)
  modified_clip = clip.fl_image(new_filtered_output)
  modified_clip.write_videofile('output.mp4'))
  
  def new_filtered_output(image):
     global RingBuffer
     inter_frame=somefunction(image)# inter_frame and image shape is same as clip_size
     RingBuffer.append(inter_frame)
     # Apply kernel
     Output =  dc + np.sum([np.asarray(RingBuffer)[j]*TempKern[j] for j in range(Depth)],axis=0)
     return Output
  </code></pre>
  
  <p>Is this the fastest way possible? I have heard that numpy roll is an option. But I don't know how to make it behave like the above code?</p>