WRAP msgpack encoder/decoder
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
polywrap_msgpack-0.1.1.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for polywrap_msgpack-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 521ed8bb480b1d31a111095f8ec4a134c4d1a214f3f9bf53b0b81707d8edaa8a |
|
MD5 | 9d14f8dc159e29335674d8c068506622 |
|
BLAKE2b-256 | 914b47f2c07906c668857a351d55c680605aecb516eaa3e333e29112104ad0e8 |