[Baypiggies] One and two dim arrays in Python

Chris Clark Chris.Clark at ingres.com
Tue Aug 26 20:07:23 CEST 2008


On 8/25/2008 5:44 PM, Chris Rebert wrote:
> ....
> This is why another way to implement multidimensional arrays in Python
> is to use a dictionary and tuples for the coordinates, e.g.:
>
> a = {}
> for x in range(x_size):
>     for y in range(y_size):
>         for z in range(z_size):
>             coords = (x,y,z)
>             a[coords] = something
>   

Interesting side topic; JJ had an interesting blog post in this area 
where he found a memory difference between tuples as the index and 
nested dicts.

http://jjinux.blogspot.com/2008/08/python-memory-conservation-tip.html


Chris



More information about the Baypiggies mailing list