You might check one of many binary encoders (like Avro, Thrift ...). The other option is to use a database, sqlite3 is pretty fast (if you schema is fixed). Otherwise you can look at some NoSQL ones (like MongoDB).