sprs icon indicating copy to clipboard operation
sprs copied to clipboard

wrap scipy matrixes in Rust

Open kno10 opened this issue 3 years ago • 3 comments

It would be great if one could use this to access scipy csr_matrix/csc_matrix from Rust for writing extensions. There is rust-numpy to work with numpy arrays from rust, but that does not include scipy sparse matrixes. But it would be great to write performance-critical operations in rust, and allow "driving" them from Python.

kno10 avatar May 08 '21 09:05 kno10

Are you looking for a python wrapper around this (#200) or something different? The crate is generic on storage type so you should be able to regenerate the matrix on the rust side if you have the raw buffers.

mulimoen avatar May 08 '21 11:05 mulimoen

No, the opposite. Process scipy csr matrixes with rust without copying them first. Use case: a user does the preprocessing into tf-idf matrix in python, then calls a fast rust library for the analysis.

kno10 avatar May 08 '21 13:05 kno10

A TryInto<CsMatViewI> impl? A direct implementation seems out of scope for this crate, as we have to pull in so many dependencies. This should be as simple as calling new_unchecked using the buffers given by scipy. Just make sure the indices are sorted on the python side.

mulimoen avatar May 09 '21 09:05 mulimoen