[SciPy-User] Sparse vector
Thu Apr 15 16:29:27 CDT 2010
I was wondering what peoples recommendations and thoughts are on
sparse vectors, i.e. long vectors where most entries are 0.
1-D numpy arrays waste a lot of memory in that case. Python
defaultdicts still use more memory then should be needed (since they
store python objects) and do not work well for numpy math operations
and slicing. Scipy.sparse has several implementations for sparse 2D
matrices which could be used for vectors, but that does not seem ideal
for clarity, efficiency and function broadcasting. Is there something
else out there or am I maybe missing a simple way to do it
In my particular case the vectors would be write-once, read-often and
maybe about 1% filled with integers. They are small enough to fit into
memory in dense form one at a time during construction.
More information about the SciPy-User