[Tutor] Problems creating very large arrays (over 10 million indices)

Zak Arntson zak@harlekin-maus.com
Tue Jul 1 11:22:01 2003


> WHen arraySize is small under 200,000 or so it works okay (though very
> very slow)  Anything larger than this and it just crashes.  I have 2
> gigs  of memory so I'm not running out of memory.
<SNIP>
> ~Edmund Dorsey

How is the data arranged? If there are many places where the value is 0,
you could try storing the data in a dictionary, where the key is the
'index'.

>>> def get_at(myDict, i):
    if myDict.has_key(i):
        return myDict[i]
    return 0

Or ... if you know there will be large spans of equal values, you could
store the value as a dictionary key, and the key's value as a list or
range.

>>> d = {}
# We have the value 12 from index 34 to 102
>>> d[34] = (34,102)

Like Edmund said, it all depends on how the data's arranged.

---
Zak Arntson
www.harlekin-maus.com - Games - Lots of 'em