MessagePack (de)serializer with Ethereum RLP encoding
Project description
This library uses a modified version of msgpack to encode and decode binary data according to the Ethereum RLP specification here https://github.com/ethereum/wiki/wiki/RLP
Because it is based on msgpack, with a back-end in cython, it is lightning fast.
This is the first release of this library, and there are likely still bugs. Use at your own risk.
Install
$ pip install msgpack-rlp-python
USAGE
RLP doesn’t specify the variable type, so all encoded data is decoded to a bytestring representation. In order to specify the variable types, we use sedes. Sedes are ways of telling the program what variable types you expect from the encoded data. In this version there are only 2 supported sedes: bytes (represented by the integer 0) and integers (represented by the integer 1). These sedes can also contained within lists or nested lists. In order to show that the sedes live within lists or nested lists, we use the standard python list notation. See below.
All lists will be decoded to tuples by default. To decode to a list set use_list = True
Sedes are only used when decoding. This library is smart enough to know what variable types are being encoded, and will convert them to the RLP spec correctly.
This is meant to be a stand-in replacement of msgpack. So the package to import is still called msgpack.
Example sedes:
var = b'\x01'
sede = 0 # A bytestring
var = 12381239
sede = 1 # An integer
var = [b'\x01', b'\x02', b'\x03', b'\x04']
sede = [0] # A list of bytestrings
var = [12312,1234,213412,213421]
sede = [1] # A list of integers
var = [b'\x01', [12312,1234]]
sede = [0,[1]] # Different types, and nested lists
Example usage without sedes. This will always decode to bytestrings.
>>> import msgpack
>>> msgpack.packb([1, 2, 3])
'b'\xc3\x01\x02\x03''
>>> msgpack.unpackb(_)
(b'\x01', b'\x02', b'\x03')
>>> msgpack.packb([1, 2, 3])
'b'\xc3\x01\x02\x03''
>>> msgpack.unpackb(_, use_list = True)
[b'\x01', b'\x02', b'\x03']
Example usage with sedes. This will decode to the variable types that you encoded from.
>>> import msgpack
>>> msgpack.packb([1, 2, 3])
'b'\xc3\x01\x02\x03''
>>> msgpack.unpackb(_)
(b'\x01', b'\x02', b'\x03')
>>> msgpack.packb([1, 2, 3])
'b'\xc3\x01\x02\x03''
>>> msgpack.unpackb(_, sedes=[1], use_list=True)
[1, 2, 3]
>>> msgpack.packb([b'\x01', [12312,1234]])
b'\xc8\x01\xc6\x820\x18\x82\x04\xd2'
>>> msgpack.unpackb(_, sedes=[0,[1]], use_list=True)
[b'\x01', [12312, 1234]]
>>> msgpack.packb([b'\x01', [12312,1234]])
b'\xc8\x01\xc6\x820\x18\x82\x04\xd2'
>>> msgpack.unpackb(_, sedes=[0,[1]], use_list=True)
[b'\x01', [12312, 1234]]
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 Distributions
Built Distributions
File details
Details for the file msgpack_rlp-0.6.3-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: msgpack_rlp-0.6.3-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 288.2 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5184316afb3ecfeb05033bd1a5e11ca1ca3a1bf22aaf314db1605a05089a9c90 |
|
MD5 | ad6891c951cc125745971462881afcba |
|
BLAKE2b-256 | cd2e6a8c8d37990e5395cfea99578e8bd016299c03d400de26b3f06b15868063 |
File details
Details for the file msgpack_rlp-0.6.3-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: msgpack_rlp-0.6.3-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 268.2 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5131666ee82477ba6da71e6c7d3e30d963130817254ac2e7f7dce23bc084ecd6 |
|
MD5 | e2bfd84902799898526529745bc767cc |
|
BLAKE2b-256 | e0c92247b4f0573c5d8a3a9098a026af6f14654d093f5f906735449f6d0b1001 |
File details
Details for the file msgpack_rlp-0.6.3-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: msgpack_rlp-0.6.3-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 281.6 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f36e84856cc7ab3bc471a122378e9593c1f414ebd40c250c29d1fd6edde301fb |
|
MD5 | 86b41e901f4cf839429f840344b81469 |
|
BLAKE2b-256 | 945fa31a960b6c376124c7c7a47512b8cc187538d4a80690a8ceeed376b7ffef |
File details
Details for the file msgpack_rlp-0.6.3-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: msgpack_rlp-0.6.3-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 259.7 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61aa00123fe63bc993c9f0b3a4d08fde64cebb76c06a46e3996ac60da461a6d6 |
|
MD5 | b4ede2d6933926521203c0e256ed5970 |
|
BLAKE2b-256 | 9c6a8a9fe5a032079ef36aeab90b5c1e64ad35f5221d559b5eb12a3e434d7c45 |
File details
Details for the file msgpack_rlp-0.6.3-cp27-cp27mu-manylinux1_x86_64.whl
.
File metadata
- Download URL: msgpack_rlp-0.6.3-cp27-cp27mu-manylinux1_x86_64.whl
- Upload date:
- Size: 264.3 kB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0282085e9265a2b46be807b984b4234cf116fbce98142f6528114088c1b3c2a3 |
|
MD5 | 4cedfd85eee8ff95c015e634ca656c03 |
|
BLAKE2b-256 | 92dcecc1c877484b073b667bb4aa7d236ceaf6b601b8737dd1c48a222a54949b |
File details
Details for the file msgpack_rlp-0.6.3-cp27-cp27mu-manylinux1_i686.whl
.
File metadata
- Download URL: msgpack_rlp-0.6.3-cp27-cp27mu-manylinux1_i686.whl
- Upload date:
- Size: 246.3 kB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2cbd8ad835382620eefccc9ba65fed703fd467c6fa4ca2b1909411b9b9f2b7d |
|
MD5 | 16fd6ab56c337e53b9b608adaa094c8a |
|
BLAKE2b-256 | 4205e8c84dfca380662f508e79f4fff11c14f8d18ba10d311a5f2f848db95591 |
File details
Details for the file msgpack_rlp-0.6.3-cp27-cp27m-manylinux1_x86_64.whl
.
File metadata
- Download URL: msgpack_rlp-0.6.3-cp27-cp27m-manylinux1_x86_64.whl
- Upload date:
- Size: 265.3 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a8a78723298cb68fff225e83589d03a84f9da01983cb05610193768df3c3862 |
|
MD5 | 6ae25ee2674ce8336d0dfa424a84f01a |
|
BLAKE2b-256 | c4e905053f2e5112efd0c1fd7ad387b0e0b03795038c3f5f9d742595a728e00f |
File details
Details for the file msgpack_rlp-0.6.3-cp27-cp27m-manylinux1_i686.whl
.
File metadata
- Download URL: msgpack_rlp-0.6.3-cp27-cp27m-manylinux1_i686.whl
- Upload date:
- Size: 246.4 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73188641e04e0d05c8aba94e8e3a021a5fe333528c02750ce1746c8c057be8e9 |
|
MD5 | c41ed7a4da643d9fc0cdc84f46dc3e50 |
|
BLAKE2b-256 | 8b70019605a7f8e59c4b3451b39297d8e6a223f3669ae58b827fadfd9d521e98 |