enhancement request: make py3 read/write py2 pickle format

random832 at fastmail.us random832 at fastmail.us
Wed Jun 10 09:38:39 EDT 2015


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']



More information about the Python-list mailing list