Memory Error while constructing Compound Dictionary
Larry Bates
lbates at swamisoft.com
Tue Sep 7 14:07:28 EDT 2004
You are asking Python to create 125,000,000
(yes that's 125 million) empty dictionaries. The hash
(key) of the dictionary takes up at least a couple
of bytes, plus the amount of space taken up by an
empty dictionary object at each entry (125 million
of them). I'm not surprised, adds up pretty quickly.
HTH,
Larry Bates
Syscon, Inc.
"Benjamin Scott" <mynewjunkaccount at hotmail.com> wrote in message
news:ccdb2248.0409070947.7f9e94ec at posting.google.com...
> Hello.
>
> I attempted to build a compound dictionary:
>
> len(Lst)=1000
> len(nuerLst)=250
> len(nuestLst)=500
>
> Dict={}
>
> for s in Lst:
> Dict[s]={}
>
> for s in Lst:
> for t in nuerLst:
> Dict[s][t]={}
>
> for s in Lst:
> for t in nuerLst:
> for r in nuestLst:
> Dict[s][t][r]={}
>
>
>
> I got the following error:
>
> Traceback (most recent call last):
> File "<pyshell#89>", line 5, in -toplevel-
> Dict[s][t][r]=[]
> MemoryError
>
>
> Specs:
>
> Python 2.3.4
> XPpro
> 4 GB RAM
>
>
> Python was utilizing 2.0 GB when the error was generated. I have
> attempted this task twice with different data sets. I got the same
> error both times.
>
> Thanks in advance for your feedback,
>
> Benjamin Scott
More information about the Python-list
mailing list