Sparse Array Implementation Python