WRAP msgpack encoding
Project description
polywrap-msgpack adds ability to encode/decode to/from msgpack format.
It provides msgpack_encode and msgpack_decode functions which allows user to encode and decode to/from msgpack bytes
It also defines the default Extension types and extension hook for custom extension types defined by WRAP standard
Quickstart
Encoding-Decoding Native types and objects
>>> from polywrap_msgpack import msgpack_decode, msgpack_encode >>> dictionary = { ... "foo": 5, ... "bar": [True, False], ... "baz": { ... "prop": "value" ... } ... } >>> encoded = msgpack_encode(dictionary) >>> decoded = msgpack_decode(encoded) >>> assert dictionary == decoded >>> print(decoded) {'foo': 5, 'bar': [True, False], 'baz': {'prop': 'value'}}
Encoding-Decoding Extension types
>>> from polywrap_msgpack import msgpack_decode, msgpack_encode, GenericMap >>> counter: GenericMap[str, int] = GenericMap({ ... "a": 3, ... "b": 2, ... "c": 5 ... }) >>> encoded = msgpack_encode(counter) >>> decoded = msgpack_decode(encoded) >>> assert counter == decoded >>> print(decoded) GenericMap({'a': 3, 'b': 2, 'c': 5})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for polywrap_msgpack-0.1.0b5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c302f4ca97bef8f1c2d3f17ac00f3feb93b3d51b6f23526d4e6c26dc41401fc |
|
MD5 | a1433f0be12868e9e2398eb4ddeb2cc4 |
|
BLAKE2b-256 | c7deeb93961ea63272430e64c1ce8e1a0689f4c14ccb555e1eba11e9a01bf0a2 |