title: Implementing 3D vectors in Python: numpy vs x,y,z fields
body: <p>I am implementing a 3D Vector class in Python.
  My vector has coordinates x, y and z (all floats), and I need to decide how to store this information. I can see at least three options here:</p>
  
  <p>1) Make three separate float fields: self.x, self.y, self.z</p>
  
  <pre><code>class Vector:
  
    def __init__(self, x, y, z):
      self.x = x
      self.y = y
      self.z = z
  </code></pre>
  
  <p>2) Make a list, say self.data, with three elements. I may also use a tuple if the objects can be constant.</p>
  
  <pre><code>class Vector:
  
    def __init__(self, x, y, z):
      self.data = [x,y,z]
  </code></pre>
  
  <p>3) Make a numpy array, say self.data, with three elements.</p>
  
  <pre><code>import numpy as np    
  
  class Vector:
  
    def __init__(self, x, y, z):
      self.data = np.array([x,y,z])
  </code></pre>
  
  <p>For options (2) and (3), I could then implement properties and setters to access the single coordinates</p>
  
  <pre><code>@property
  def x(self):
    return self.data[0]
  </code></pre>
  
  <p>4) Why not having some redundancy? I could have both a list (or tuple, or numpy array) and separate fields x, y and z.</p>
  
  <p>The class is meant to be used to perform common operations such as vector addition, inner product, cross product, rotation, etc. Performance of these operations needs to be taken into account.</p>
  
  <p>Is there a solution that I should prefer, and why?</p>