A sparse vector is a 1D numerical list where most (say, more than 95% of)
values will be 0
(or some other default) and for reasons of memory efficiency
you don't wish to store these.
(cf. Sparse array)
This implementation has a similar interface to Python's 1D numpy.ndarray
but stores the values and indices in linked lists to preserve memory.
sparse_vector
is for numerical data only, if you want any type of data, have
a look at sparse_list, the parent
library, a dictionary-of-keys implementation of a sparse list in python.
If you need 2D matrices, have a look at scipy.sparse
, they also have a
linked lists implementation, lil_matrix
.
Available on the cheeseshop.
Installation is simply:
$ pip install sparse_vector
See the unit-tests!
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Ensure the tests pass for all Pythons in
.travis.yml <https://github.com/johnsyweb/python_sparse_vector/blob/master/.travis.yml>
__ - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- johnsyweb for the original
sparse_list
.