3 ms·
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
by AussieWog93 4y ago
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.
- bobbylarrybobby 4y agoThe 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).
- cochne 4y agoI implemented a shoddy version of this once (before accepting that pickles are worth it) only took like 100 LOC for serialization and deserialization.
- npage97 4y agoThere is dataclasses-json which does this https://pypi.org/project/dataclasses-json/ https://pypi.org/project/dataclasses-json/
- henrydark 4y agoI'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
- thraxil 4y agoThe problem is that "the average home-made Python script" frequently ends up turning into a critical production system.
- tpoacher 4y agotrue of any language