title: What is the best way to handle 3d voxel data?
body: <p>At the moment I am storing voxels in a simple list. ([0,0,0,0,0,1,0,0,1 ... ])
  To retrieve voxel positon in the list I use this function:</p>
  
  <pre><code>def getBlockKey(self, x, y, z):
  
      blockX = x % CFG_CHUNK_SIZE
      blockY = y % CFG_CHUNK_SIZE
      blockZ = z % CFG_CHUNK_SIZE
  
      return blockX + blockY * CFG_CHUNK_SIZE + blockZ * (CFG_CHUNK_SIZE * CFG_CHUNK_SIZE)
  </code></pre>
  
  <p>But this is very slow when handling big amounts of data. For example iterating over each cube in 256*256*256 chunk takes 50 seconds.</p>
  
  <p>I guess it'd be faster to use dict, but it uses way too much memory.</p>
  
  <p>Could you help me to find a compromise between these two?</p>