title: "Linked lists" in numpy array? How to avoid duplicate entries
body: <p>I have a list of lists right now in python, containing the results of some calculation between every element of a 2D numpy array. (I found the difference between every value in the 2D array).
  In an effort to be efficient and only perform this calculation once (since the absolute difference between X and Y is the same for both X and Y, this should only be calculated once), </p>
  
  <p>I went through and got a big list of results.</p>
  
  <p>To give you an idea, say I'm working with one variable in my array:  </p>
  
  <blockquote>
    <p>[<br>
       [a],  {Other stuff is here(more variables), but they can be ignored for the example}<br>
       [b],   ~~<br>
       [c],   ~~<br>
       [d],   ~~<br>
       [e],   ~~<br>
    ]</p>
  </blockquote>
  
  <p>^(where a, b,c... are actual numbers)</p>
  
  <p>I need to find the absolute difference between every value of this variable, so I did, and put the results as they were computed together in a list of lists like this:  </p>
  
  <blockquote>
    <p>[<br>
       [(a-b), (a-c), (a-d), (a-e)],<br>
       [(b-c), (b-d), (b-e)],<br>
       [(c-d), (c-e)],<br>
       [(d-e)],<br>
       ]  </p>
  </blockquote>
  
  <p>What I want to have is:  </p>
  
  <blockquote>
    <p>[<br>
       [(a-b), (a-c), (a-d), (a-e)],<br>
       [(b-a), (b-c), (b-d), (b-e)],<br>
       [(c-a), (c-b), (c-d), (c-e)],<br>
       [(d-a), (d-b), (d-c), (d-e)],<br>
       ]   </p>
  </blockquote>
  
  <p>But notice how, since I'm working with absolute difference (e.g. absolute_value(a-b) ),
  I shouldn't have to go through the list again and recompute the differences, 
  since abs(a-b) is the same as abs(b-a).</p>
  
  <p>Ideally, I also shouldn't have to store the number abs(a-b) twice either!
  In regular python lists, I can set the value of a list to point to another list's value,
  like:  </p>
  
  <blockquote>
    <p>.>>> lemons = [1,2,3,4,5]<br>
    .>>> oranges= [999]<br>
    .>>> oranges[0] = lemons<br>
    .>>> oranges<br>
    [[1,2,3,4,5]]  </p>
  </blockquote>
  
  <p>In this way, the values [1,2,3,4,5] are only stored in lemons; oranges simply references these values. Namely, there exists a link between the two lists.
  Is such a thing possible in a numpy array?
  It would look something like:</p>
  
  <blockquote>
    <p>[<br>
       [(a-b),                           (a-c), (a-d), (a-e)],<br>
       [(link to [0,0]),                 (b-c), (b-d), (b-e)],<br>
       [(link to [0,1], (link to [1,1]), (c-b), (c-d), (c-e)],<br>
       [(etc),           (etc),          (etc), (etc), (d-e)],<br>
       ]   </p>
  </blockquote>
  
  <p>So values aren't stored twice. I'm working with a pretty large amount of values, so it really matters to me that they aren't stored twice.
  If numpy cannot support this, do you have any other suggestions regarding how I might go about this? </p>
  
  <p>Thank you for your time. </p>