/serialization-benchmark

serialization benchmarks in python

Primary LanguagePython

benchmark performance of popular serialization libraries

  • json
  • protocol buffer
  • msgpack

To run the benchmarks,

make test
make run

results

python2 (Python 2.7.9)

encodedecode
json0.460.59
pb0.160.20
msgpack3.734.23

python3 (Python 3.4.2)

encodedecode
json0.450.35
pb0.160.20
msgpack2.923.00

pypy (PyPy 2.4.0 with GCC 4.9.2, Python 2.7.8)

encodedecode
json0.370.11
pb0.700.31
msgpack0.320.71
umsgpack0.220.40
msgpack-pypy0.420.30

Note: msgpack-pypy is in beta state. Other libraries are in stable state.

summary

For py2/py3, pb > json >> msgpack. For pypy, json > pb = msgpack.

Json is a good choice. It doesn’t have a big performance penalty.

TODO Why msgpack has so bad performance under cpython?