Diff between object graphs?
cfkaran2 at gmail.com
Fri Apr 24 14:42:35 CEST 2015
On Apr 23, 2015, at 11:05 AM, Steve Smaldone <smaldone at gmail.com> wrote:
> On Thu, Apr 23, 2015 at 6:34 AM, Cem Karan <cfkaran2 at gmail.com> wrote:
> On Apr 23, 2015, at 1:59 AM, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> > On Thursday 23 April 2015 11:53, Cem Karan wrote:
> >> Precisely. In order to make my simulations more realistic, I use a lot of
> >> random numbers. I can fake things by keeping the seed to the generator,
> >> but if I want to do any sort of hardware in the loop simulations, then
> >> that approach won't work.
> > That's exactly why we have *pseudo* random number generators. They are
> > statistically indistinguishable from "real" randomness, but repeatable when
> > needed.
> Which is why is why I mentioned keeping the seed above. The problem is that I eventually want to do hardware in the loop, which will involve IO between the simulation machine and the actual robots, and IO timing is imprecise and uncontrollable. That is where not recording something becomes lossy. That said, the mere act of trying to record everything is going to cause timing issues, so I guess I'm over thinking things yet again.
> Thanks for the help everyone, its helped me clarify what I need to do in my mind.
> Well, you could achieve this on Linux by using the rdiff library. Not exactly a purely Python solution, but it would give you file-based diffs.
> Basically, what you could do is write the first file. Then for each subsequent saves, write out the file (as a temp file) and issue shell commands (via the Python script) to calculate the diffs of the new file against the first (basis) file. Once you remove the temp files, you'd have a full first save and a set of diffs against that file. You could rehydrate any save you want by applying the diff to the basis.
> If you work on it a bit, you might even be able to avoid the temp file saves by using pipes in the shell command.
> Of course, I haven't tested this so there may be non-obvious issues with diffing between subsequent pickled saves, but it seems that it should work on the surface.
That might work... although I'm running on OS X right now, once I get to the hardware in the loop part, it's all going to be some flavor of Linux. I'll look into it... thanks!
More information about the Python-list