[Python-ideas] `to_file()` method for strings

Chris Barker - NOAA Federal chris.barker at noaa.gov
Mon Mar 28 11:30:09 EDT 2016


> On Mar 24, 2016, at 7:22 PM, Nick Coghlan : what if we had a JSON-based save builtin that wrote
> UTF-8 encoded files based on json.dump()?

I've been think about this for a while, but would rather have a
"pyson" format -- I.e. Python literals, rather than JSON. This would
preserve the tuple vs list and integer vs float distinction, and allow
more options for dictionary keys.(and sets?).

Granted, you'd lose the interoperability, but for the quick saving and
loading of data, it'd be pretty nice.

There is also JSON pickle:

https://jsonpickle.github.io

Though as I understand it, it has the same security issues as pickle.

But could we make a not-quite-as-complete pickle-like protocol that
could save and load arbitrary objects, without ever running arbitrary
code?

-CHB


More information about the Python-ideas mailing list