Hi Kundar,

Apologies, I forgot to reply to this.

On May 7, 2007, at 2:15 PM, [EMAIL PROTECTED] wrote:


Hi Daniel,

Thank you for the sharing of pickling objects. Can the whole data of each step be written in the same one file?

Yes. You can create a dictionary, tuple or list with everything you wish to include. Dictionary is the best as you can label the entries and see what you saved at a later date. I have never looked into doing a state dump
with python, but probably ought to.

You can do essentially the same thing with shelve. See this:

   <http://docs.python.org/lib/node329.html>

After reading this it is clear that one possibility for a state dump is as follows:

   import shelve
   d = shelve.open('blah')
   for k in globals().keys():
         try:
                d[k] = globals()[k]
         except:
                pass
   d.close()

That should save all objects that can be pickled. I haven't tested this, it is just a thought.

Shelve allows you to dynamically add data to the file. You could then create one file for the entire simulation.

Also, documentation on data persistence is here:

    <http://docs.python.org/lib/persistence.html>

I used the pygist on WinXP. Do you have any suggestion for a better environment?

You could try matplotlib. Matplotlib gives better plots and doesn't leak memory. However,
it is much slower.

You may be able to avoid gist memory leak by recreating the gist viewer at each step and deleting it.


--
Daniel Wheeler


Reply via email to