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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -