Hacker News new | ask | show | jobs
by WorldMaker 1402 days ago
Obviously one of those cases where everyone's mileage varies, but the default JSON serialization has covered 99% of everything I've ever serialized/deserialized in Python without needing to write a to_json/from_json by hand. Needing those for 1% of cases seems fine. But also maybe I lean into duck typing a whole lot more than you do at the serialization boundary and don't need a lot of specific class types coming from JSON as long as the data is all in the same shape. You may think that's "primitives obsession", and I may think that a giant class hierarchy of custom objects is a bit non-Pythonic. We're both right, which is why, again, your mileage may vary here.
1 comments

It just means that you usually deal with data that has a natural tree structure. The moment it becomes a graph, hands-off JSON serialization is broken - but Pickle isn't.
At a possibly serialized boundary sure. That doesn't mean I don't work with graphs, though, just that I guess I don't expect graphs to be entirely reified in memory at all times if I'm going to duck type walk through them. We all have different habits, of course.