Yeah, I'm not surprised the simplest approaches are calling slow dense generic fallbacks.
One thing that might be interesting to do, if you really need the matrix to be CSR once it's in Python, would be to compare Julia's sparse transpose to scipy's. Of course if you know your matrix is symmetric then you can even construct it as if it's csr in the first place. On Sunday, June 21, 2015 at 12:39:22 AM UTC-7, Christoph Ortner wrote: > > It seems this was it. > > If I do the following: > > function py_csc(A::SparseMatrixCSC) > # create an empty sparse matrix in Python > Apy = scipy_sparse.csc_matrix(size(A)) > # write the values > Apy[:data] = copy(A.nzval) > # write the indices > Apy[:indices] = A.rowval - 1 > Apy[:indptr] = A.colptr - 1 > return Apy > end > py_csr(A::SparseMatrixCSC) = py_csc(A)[:tocsr]() > > > then replace > > # B_py_csr = scipy_sparse.csr_matrix(B) > B_py_csr = py_csr(B) > > I now get reasonably timings. > > >
