QPack is a fast and efficient serialization format like MessagePack. One key difference is flexible map and array support which allows to write directly to a qpack buffer without the need to know the size for the map or array beforehand.
From PyPI (recommend)
pip install qpack
From source code
python setup.py install
qpack.packb(object)
Unpack serialized data. When decode is left None, each string will be returned as bytes.
qpack.unpackb(qp, decode=None, ignore_decode_errors=False, use_tuples=False)
importqpack# define some test datadata= {'name': 'Iris', 'age': 9}
# serialize into qpack formatqp=qpack.packb(data)
# unpack the serialized dataunpacked=qpack.unpackb(qp, decode='utf-8')
# left see what we've got...print(unpacked) # {'name': 'Iris', 'age': 3}