Anyone Know a Great Sparse One Dimensional Array Library in Python?
Posted
by TheJacobTaylor
on Stack Overflow
See other posts from Stack Overflow
or by TheJacobTaylor
Published on 2010-06-09T03:58:24Z
Indexed on
2010/06/09
4:02 UTC
Read the original article
Hit count: 227
I am working on an algorithm in Python that uses arrays heavily. The arrays are typically sparse and are read from and written to constantly. I am currently using relatively large native arrays and the performance is good but the memory usage is high (as expected).
I would like to be able to have the array implementation not waste space for values that are not used and allow an index offset other than zero. As an example, if my numbers start at 1,000,000 I would like to be able to index my array starting at 1,000,000 and not be required to waste memory with a million unused values.
Array reads and writes needs to be fast. Expanding into new territory can be a small delay but reads and writes should be O(1) if possible.
Does anybody know of a library that can do it?
Thanks!
© Stack Overflow or respective owner