enhancement request: make py3 read/write py2 pickle format

Chris Angelico rosuav at gmail.com
Tue Jun 9 19:06:27 EDT 2015


On Wed, Jun 10, 2015 at 6:07 AM, Devin Jeanpierre
<jeanpierreda at gmail.com> wrote:
> There's a lot of subtle issues with pickle compatibility. e.g.
> old-style vs new-style classes. It's kinda hard and it's better to
> give up. I definitely agree it's better to use something else instead.
> For example, we switched to using protocol buffers, which have much
> better compatibility properties and are a bit more testable to boot
> (since text format protobufs are always output in a canonical (sorted)
> form.)

Or use JSON, if your data fits within that structure. It's easy to
read and write, it's human-readable, and it's safe (no chance of
arbitrary code execution). Forcing yourself to use a format that can
basically be processed by ast.literal_eval() is a good discipline -
means you don't accidentally save/load too much.

ChrisA



More information about the Python-list mailing list