On Wed, Jun 10, 2015, at 08:08, Marko Rauhamaa wrote: > You can't serialize/migrate arbitrary objects. Consider open TCP > connections, open files and other objects that extend outside the Python > VM. Also objects hold references to each other, leading to a huge > reference mesh. > > For example: > > a.buddy = b > b.buddy = a > with open("a", "wb") as f: f.write(serialize(a)) > with open("b", "wb") as f: f.write(serialize(b)) > > with open("a", "rb") as f: aa = deserialize(f.read()) > with open("b", "rb") as f: bb = deserialize(f.read()) > assert aa.buddy is bb
Of course, if you serialize a single dict with e.g. {'a': a, 'b': b}, you can expect (with advanced serialization tools, anyway - I suspect JSON will just make a mess or exceed maximum recursion depth) result['a'].buddy is result['b'] -- https://mail.python.org/mailman/listinfo/python-list