2

I am looking for the most efficient way to save data from one run of a python script to the next. My script generates a list , say presentList . The list is made up of a number of integers. Next time the script runs I want to use that list again as previousList. I would prefer that this data be written and read from memory rather than disk since my script runs quite often and I don't want to write so often to my disk. Can I use pickle with BytesIO to accomplish this? I am also using Animation Nodes. Perhaps there is a way to send the list to and from Animation Nodes to make the data persistent? Thanks for any advice on this. Perhaps this would be better asked on a python forum.

Jim Ruxton
  • 313
  • 1
  • 8

1 Answers1

1

Based on the comment Omar posted I found that I could simply use the python statements setattr() to save my list and getattr() to retrieve it. In this case I stored the list as an attribute in animation_nodes as shown in Omar's example however I assume I could have stored it in any object in my scene. This allowed me to have data persist between running instances of my python script,

Jim Ruxton
  • 313
  • 1
  • 8
  • Is https://stackoverflow.com/questions/4075190/what-is-getattr-exactly-and-how-do-i-use-it the getattr() you're referring to? – Ron Jensen Aug 01 '21 at 18:23