I have a complex data structure (user-defined type) on which a large number of independent calculations are performed. The data structure is basically immutable. I say basically, because though the interface looks immutable, internally some lazy-evaluation is going on. Some of the lazily calculated attributes are stored in dictionaries (return values of costly functions by input parameter). I would like to use Pythons multiprocessing module to parallelize these calculations. There are two questions on my mind.
- How do I best share the data-structure between processes?
- Is there a way to handle the lazy-evaluation problem without using locks (multiple processes write the same value)?
Thanks in advance for any answers, comments or enlightening questions!
independent calculationis submitted, do you know before the start which lazy attributes are needed?