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
Built Distribution
File details
Details for the file polywrap_msgpack-0.1.2.tar.gz
.
File metadata
- Download URL: polywrap_msgpack-0.1.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36cb8d708d77fda3426118cac9d714f33fd7b52d94873a1f66cb6d6d8b7d13ed |
|
MD5 | 6ec05d47979797dc408aa14ee226a07d |
|
BLAKE2b-256 | b612fb57151fe572525eaaaa0b874cc8c062d8d462447369feeadb7bcd3438ac |
File details
Details for the file polywrap_msgpack-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: polywrap_msgpack-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5bc6ac3d8b0e69e1256d5b91d6d6986f544383df6da90bba138b25a9864a6e8 |
|
MD5 | 0217e118b59bff6360b6a8ecd4234b3e |
|
BLAKE2b-256 | 359816115b38843c8badc88b41c219a1f21cc7f5b3f14d817afa92bf2588d2ee |