I am working on an algorithm in Python that uses arrays of int64s 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!
Updated to mention int64 as the data type.