title: Loading Matlab sparse matrix saved with -v7.3 (HDF5) into Python and operating on it
body: <p>I'm new to python, coming from matlab. I have a large sparse matrix saved in matlab v7.3 (HDF5) format. I've so far found two ways of loading in the file, using <code>h5py</code> and <code>tables</code>. However operating on the matrix seems to be extremely slow after either. For example, in matlab:</p>
  
  <pre><code>&gt;&gt; whos     
    Name           Size                   Bytes  Class     Attributes
  
    M      11337x133338            77124408  double    sparse    
  
  &gt;&gt; tic, sum(M(:)); toc
  Elapsed time is 0.086233 seconds.
  </code></pre>
  
  <p>Using tables:</p>
  
  <pre><code>t = time.time()
  sum(f.root.M.data)
  elapsed = time.time() - t
  print elapsed
  35.929461956
  </code></pre>
  
  <p>Using h5py:</p>
  
  <pre><code>t = time.time()
  sum(f["M"]["data"])
  elapsed = time.time() - t
  print elapsed
  </code></pre>
  
  <p>(I gave up waiting ...)</p>
  
  <p>[EDIT]</p>
  
  <p>Based on the comments from @bpgergo, I should add that I've tried converting the result loaded in by <code>h5py</code> (<code>f</code>) into a <code>numpy</code> array or a <code>scipy</code> sparse array in the following two ways:</p>
  
  <pre><code>from scipy import sparse
  A = sparse.csc_matrix((f["M"]["data"], f["M"]["ir"], f["tfidf"]["jc"]))
  </code></pre>
  
  <p>or</p>
  
  <pre><code>data = numpy.asarray(f["M"]["data"])
  ir = numpy.asarray(f["M"]["ir"])
  jc = numpy.asarray(f["M"]["jc"])    
      A = sparse.coo_matrix(data, (ir, jc))
  </code></pre>
  
  <p>but both of these operations are extremely slow as well. </p>
  
  <p>Is there something I'm missing here?</p>