More idiomatic python + more support for sparse matrices