title: iterating over a deque in two directions efficiently in Python
body: <p>I have a deque, let's call it <code>deq</code>. I need to iterate over it from both ends, and I will not be modifying it at all during these iterations.</p>
  
  <p>Naturally, I don't want to create <em>another</em> deque.
  I've considered <code>reversed</code>, but I don't know if it actually creates any copies. If, for example, I were write:</p>
  
  <pre><code>reversed_deq = reversed(deq)
  </code></pre>
  
  <p>will it reference the exact same memory locations, but simply iterate over it in reverse, without using any more memory/time?</p>
  
  <p>That seems like the logical way to go for a double-ended queue, but I want to make sure I'm not missing anything.</p>
  
  <p>I can't find the code for deque (usually they have a "python equivalent" of these things, but I couldn't find it), and for some reason - no matter what I run - <code>timeit</code> always gives me something between 15 and 16 ns (for everything I try to time, not just this)</p>