Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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


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).


There is dataclasses-json which does this

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


I implemented a shoddy version of this once (before accepting that pickles are worth it) only took like 100 LOC for serialization and deserialization.


The problem is that "the average home-made Python script" frequently ends up turning into a critical production system.


true of any language




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: