Diff between object graphs?

Cem Karan cfkaran2 at gmail.com
Wed Apr 22 12:07:25 CEST 2015


Hi all, I need some help.  I'm working on a simple event-based simulator for my dissertation research. The simulator has state information that I want to analyze as a post-simulation step, so I currently save (pickle) the entire simulator every time an event occurs; this lets me analyze the simulation at any moment in time, and ask questions that I haven't thought of yet.  The problem is that pickling this amount of data is both time-consuming and a space hog.  This is true even when using bz2.open() to create a compressed file on the fly.  

This leaves me with two choices; first, pick the data I want to save, and second, find a way of generating diffs between object graphs.  Since I don't yet know all the questions I want to ask, I don't want to throw away information prematurely, which is why I would prefer to avoid scenario 1.  

So that brings up possibility two; generating diffs between object graphs.  I've searched around in the standard library and on pypi, but I haven't yet found a library that does what I want.  Does anyone know of something that does?

Basically, I want something with the following ability:

Object_graph_2 - Object_graph_1 = diff_2_1
Object_graph_1 + diff_2_1 = Object_graph_2

The object graphs are already pickleable, and the diffs must be, or this won't work.  I can use deepcopy to ensure the two object graphs are completely separate, so the diffing engine doesn't need to worry about that part.

Anyone know of such a thing?

Thanks,
Cem Karan


More information about the Python-list mailing list