I’m trying to figure out how to create a large dict that I can use throughout my network.
Storage looks like the right way to go, except that it actually writes the contents to disk when saving the toe file.
I’m reading in a Large file, doing some transformation in a script DAT to prep the data for the rest of my network. The result is several dicts, whose size is too large to write to disk every time i save touch.
Right now my hack has been to write out each dict as a table in the script DAT. Then when I want to use it I wire it up to Script DATs on the other end, and have them read in the table, and convert it back into a dict. Obviously not ideal, and the latency on reading/writing out to DAT tables is dragging.
We are thinking about how to best add temporary storage to nodes. In the meantime one solution is this:
Have a module in /local/modules that is nothing but
dict = {} # initialize an empty dictionary.
Now you can access the module, and access the dict variable using
mod.modulename.dict
It will keep its contents as long as you don’t change the text in the module, but it won’t be saved out in the .toe file (will restart as empty every time you start).
I’m trying this technique out. The problem I am coming up against, which I’m sure is part of the ongoing python integration issues is that I can’t get the data to update when referencing it with an operator and changing it with another.
Say I use a panel to change one of the dictionary items, a float, and then have a constant chop using an expression like “mod.myMod.dict[‘myNumber’]” the value only updates when I force cook the constant CHOP.
Interestingly, when I assign the panelValue directly to the dictionary item (instead of converting to a float) the constant CHOP will update constantly, because I imagine it is now fully tied to that panelValue itself through the dictionary reference. This isn’t exactly how I’d like to do things though, because I don’t want the panelValue and my number to be the same object, I don’t think…
Use an examine dat. Set it’s operator parameter to whatever node has the storage you’re interested in. Then you have a couple choices off the top of my head.
In the constant chop, reference the examine dat’s cell in your chop.
Alternatively, use a dat to chop instead of the constant chop + expression.