Depending on your platform (os, hardware, compiler) you can even do something silly like write packed structs and then write those to disk (or send them over sockets) and cast back.<p>Mostly it works if you know the hardware and compiler will stay the same (as in packed struct representation will stay the same). It is basically a poor man&#x27;s Cap&#x27;n&#x27;Proto or Flatbuffers.<p>As for speed, buffering strategy (size and how often fsync is done) will often dominate other stuff. I remember doing a benchmark between C++ and Python for loading and saving data. Python won hands down. The reason was because it had better buffer size defaults. There is also trickery and configuration involved in your page cache params are setup and the schedule of how dirty pages are flushed (if you don&#x27;t fsync).<p>&gt; If you’re interested in how fast using read(2) is, it’s essentially the same speed: 5437341 ns if I’m reading directly into the std::vector.<p>Yap, mmap is not always better, it is more complicated and depending on access pattern not always worth it.