News for hackers. Stuff that matters.
Re:Don't Pickle Your Data by AussieWog93 on Thursday August 11, 2022 @06:57PM (#32432856)
From the conclusion of the article: >Pickle on the other hand is slow, insecure, and can be only parsed in Python. The only real advantage to pickle is that it can serialize arbitrary Python objects

ie, a bunch of drawbacks that don't really matter at all for the average home-made Python script, plus the "minor" advantage of being able to pickle literally anything and have it "just work".

None of the other options out there let you build a foolproof "save button" in 3 lines of code.

Re:Don't Pickle Your Data by henrydark on Friday August 12, 2022 @01:49AM (#32435071)
I'm sure that most python developers who have worked with pickle for more than 3 lines of code can confirm that pickle does not in fact just work
Re:Don't Pickle Your Data by bobbylarrybobby on Thursday August 11, 2022 @09:25PM (#32433834)
The real question is why doesn't Python have something like a class decorator`@json.interchangeable` that you can apply to a class -- maybe dataclasses only? -- to have json (de)serialization be only three lines of code (or less).
Re:Don't Pickle Your Data by npage97 on Thursday August 11, 2022 @11:03PM (#32434329)
There is dataclasses-json which does this

https://pypi.org/project/dataclasses-json/

Re:Don't Pickle Your Data by cochne on Thursday August 11, 2022 @10:03PM (#32434017)
I implemented a shoddy version of this once (before accepting that pickles are worth it) only took like 100 LOC for serialization and deserialization.
Re:Don't Pickle Your Data by thraxil on Friday August 12, 2022 @04:58AM (#32436056)
The problem is that "the average home-made Python script" frequently ends up turning into a critical production system.
Re:Don't Pickle Your Data by tpoacher on Friday August 12, 2022 @08:21AM (#32437395)
true of any language