Serde_json vs. serde_yaml serialization speed?

I haven't been able to find a comparison of speed. I've been using serde_yaml to checkpoint simulation state, but the files are getting large and slow, and I'm wondering if it's worth considering moving to serde_json. I know I could be more efficient with a binary format, but I prefer the human-readability and python-readability of yaml or json. Plus, I like being able to add fields (with default values) without invalidating older files.

Any pointers to a speed or size comparison?

1 Like

It should be easy to switch one to another, so you may be able to just change it and measure.

Also consider msgpack and CBOR. They should be usable in Python too, and they're much more compact and likely quicker to parse.

1 Like

Serde_yaml isn't optimized at all, I wouldn't be surprised if serde_json is something like 20x faster.

2 Likes

I've experimented with cbor and Jason, and both are a significant improvement over yaml in terms of speed, with cbor winning by a factor is two or so. I haven't yet gotten to the point of doing analysis in Python, though.