Problem with an huge dictionary

keobox keobox at gmail.com
Fri May 21 11:54:44 EDT 2010


On 20 Mag, 12:58, Thomas Lehmann <t.lehm... at rtsgroup.net> wrote:
> > The question is:
> > Is there a limit on the number of entries a dictionary can have i
> > jython?
>
> > I wrote a little app where my data is stored in a huge dictionary
> > (11746 entries) generated with a python script.
> > When I try to import the dictionary, jython complains with the
> > following message:
>
> 1) You did not say what you have saved (content of your dictionary).

- As you can see I received the error when I tried to import
jmoco_event_data.py module from the jython interpreter prompt.
- The "import" will cause the module compilation, jython will produce
a .class file instead of .pyc.
- jmoco_event_data.py contains 4 dictionaries:

typesValToName={
220:'EMS_EVENT_EMS_INTERNAL_BASE',
221:'EMS_EVENT_INTERNAL_TYPE_BASE',
222:'EMS_EVENT_INTERNAL_N_E_P_M_EVENT',
223:'EMS_EVENT_INTERNAL_N_E_ALARM_RCVD',
224:'EMS_EVENT_NE_SPECIFIC_BASE',
... 11746 entries int key: string value
}

typesNameToVal={
'EMS_EVENT_EMS_INTERNAL_BASE':220,
'EMS_EVENT_INTERNAL_TYPE_BASE':221,
'EMS_EVENT_INTERNAL_N_E_P_M_EVENT':222,
'EMS_EVENT_INTERNAL_N_E_ALARM_RCVD':223,
'EMS_EVENT_NE_SPECIFIC_BASE':224,
... total 11746 entries string key: int value
}

causesValToName={
0:'NOT_APPLICABLE_UNKNOWN',
1:'SOFTWARE_CAUSE_UNKNOWN',
2:'ABSENT_MODULE',
3:'FAULTY_MODULE',
... 483 entries int key: string value
}

causesNameToVal={
'NOT_APPLICABLE_UNKNOWN':0,
'SOFTWARE_CAUSE_UNKNOWN':1,
'ABSENT_MODULE':2,
'FAULTY_MODULE':3,
... 483 entries string key: int value
}

> 2) You did not say how you have saved.

The dictionaries are in the jmoco_event_data.py module.

> From the callstack - also I have never used jython - it looks like
> that
> there is a try to create a class. It looks like - I may be wrong -
> that
> you have saved user objects in your dictionary - have you?

Nope, the dictionaries are only int to string mappings and string to
int mappings

> If so you might fail on loading those objects - especially when your
> program
> does not have the code for it.

The failure happens during module's import, so my question is: Is
jython able to handle such big dictionaries?

> More details are required...

jmoco_event_data.py has a size of roughly 700KB.



More information about the Python-list mailing list