title: Getting List indexed memory locations. Not value locations but List index locations
body: <p>From what I am aware, Python stores Lists as "arrays" in memory; however, the "array" stores pointers to the PyObject's in the List.</p>
  
  <p>I am using <code>hex(id(...))</code> to view the memory addresses of the List and of all the items in the list. But I also want to see the memory location of the "array" positions.</p>
  
  <p>This is my interpreter code so far...</p>
  
  <pre><code>&gt;&gt;&gt; def memory_locations_of(value):
          for index, element in enumerate(value):
              print("{: &lt;15}{}\n{: &lt;15}{}\n".format("index[" + str(index) + "] ", hex(id(element)), str(element), hex(id(str(element)))))
  
  &gt;&gt;&gt; a = ["hello", "world", "!", "!"]
  &gt;&gt;&gt; a
  ['hello', 'world', '!', '!']
  
  &gt;&gt;&gt; memory_locations_of(a)
  index[0]       0x34b4bc0
  hello          0x34b4bc0
  index[1]       0x4053dc0
  world          0x4053dc0
  index[2]       0x3616620
  !              0x3616620
  index[3]       0x3616620
  !              0x3616620
  
  &gt;&gt;&gt; a[0] = "Hello"
  &gt;&gt;&gt; a
  ['Hello', 'world', '!', '!']
  
  &gt;&gt;&gt; memory_locations_of(a)
  index[0]       0x406e260
  Hello          0x406e260
  index[1]       0x4053dc0
  world          0x4053dc0
  index[2]       0x3616620
  !              0x3616620
  index[3]       0x3616620
  !              0x3616620
  
  &gt;&gt;&gt; hex(id(a))
  '0x3f7cc10'
  </code></pre>
  
  <p>The last 2 lines are the closest memory location that I want. That memory location is the location of the actual List. That should also be the location of the actual a[0] position (or very close to it). I also want to get the real location of a<a href="https://i.stack.imgur.com/K26b0.png" rel="nofollow noreferrer">1</a>, a[2], and a[3]. It based on my code they should be at <code>'0x3f7cc10' + "index_offset"</code>.</p>
  
  <p>Is there an easy way of getting this or is it rather contrived?</p>
  
  <p><a href="https://i.stack.imgur.com/K26b0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K26b0.png" alt=""></a></p>