python - csr_matrix row indexing is much slower than dense array? -
i created huge sparse matrix in csr
format, , reason, need iterate through rows (randomly) , dot
operations, , found code much slower using dense array, here benchmark.
in [1]: = sp.csr_matrix(np.random.rand(10000, 10000)) in [2]: b = a.todense() in [126]: %timeit a[1357] 10000 loops, best of 3: 78.1 µs per loop in [127]: %timeit b[1357] slowest run took 6.80 times longer fastest. mean intermediate result being cached. 100000 loops, best of 3: 2.49 µs per loop
dense array row indexing 30x faster csr_matrix
, doing right, , how improve it?
Comments
Post a Comment