sproto encode and decode
Project description
✨ Pysproto ✨
Another Pythonic Sproto Python binding for sproto
Powered by cython, high performance, pythonic
Usage
- install
pip install sproto
- encode & decode
from pysproto import parse, parse_ast, Sproto
ast = parse(""".package {
type 0 : integer
session 1 : integer
}""")
dump = parse_ast(ast)
proto = Sproto(dump)
tp = proto.querytype("package")
encoded = tp.encode({"type": 1, "session": 2})
print(tp.decode(encoded))
- Public functions
from typing import Union, Tuple, Optional
class Sproto:
def dump(self)->None: ...
def protocol(self, tag_or_name: Union[int, str]) -> Tuple[Union[int, str], Optional["SprotoType"], Optional["SprotoType"]]: ...
def querytype(self, type_name) -> "SprotoType": ...
def sproto_protoresponse(self, intproto) -> int: ...
class SprotoError(Exception): ...
class SprotoType:
@classmethod
def __init__(self, *args, **kwargs) -> None: ...
def decode(self, buffer: bytes) -> dict: ...
def encode(self, data: dict) -> bytes: ...
def encode_into(self, data: dict, buffer: bytearray) -> int: ...
def pack(data: bytes) -> bytes: ...
def pack_into(data: bytes, buffer: bytearray) -> int: ...
def unpack(data: bytes) -> bytes: ...
def unpack_into(data: bytes, buffer: bytearray) -> int: ...
xx_into
functions accepts buffer protocol objects, which is zerocopy.
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
sproto-0.1.1rc1.tar.gz
(186.2 kB
view hashes)
Built Distributions
Close
Hashes for sproto-0.1.1rc1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1946590f10d59d8151fb0d93f24c91f968b8395d4e0191feb77e3e1befcadc88 |
|
MD5 | 65bf245128a29418bb8cd003fbc433d2 |
|
BLAKE2b-256 | 7662a7c06bcd7617db396a8aeada2b59be72fa471f636748ad63e1430ab7f2cf |
Close
Hashes for sproto-0.1.1rc1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 276d42567f9b03876ed2cc1506b2c4038f28469fd2a1c6f2de18801acfaab681 |
|
MD5 | 88fe1ad06147cce215b83b57bd281c66 |
|
BLAKE2b-256 | 448383f01ed186ee01a41e9ae15eea2156ac9273085d2cbc72dccb31480b8b92 |
Close
Hashes for sproto-0.1.1rc1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2d66afdad554a908592309c7cdd6af61b2b71a44c60abf940b451a5fa63fcf7 |
|
MD5 | cf06aff324c943f2c11aecd04cc46207 |
|
BLAKE2b-256 | fc0b2df67216c5dea9fe9624af169bc133103f920f4d48c24f6c7d7356726aea |
Close
Hashes for sproto-0.1.1rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5e671cd51d01e0b350fa2cf9284a9e7287f72dafec02f4584b036cbf038bdf9 |
|
MD5 | 3b33970bdb46a48a26bbd5b3a876f086 |
|
BLAKE2b-256 | 2d8977bac7fed29a4767c6cb2921571f8741f191df2453850f68f2ae10096ec1 |
Close
Hashes for sproto-0.1.1rc1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d870457360559b010646eb66aabec15067bda10f99e3d19f01d70f8fb0a2aa43 |
|
MD5 | 6b27cf589425cf5895422d93daf73030 |
|
BLAKE2b-256 | f1ead818548c77d604a3715256e9cbfbeb97a5d45f4bba86ab438a241aeacfd2 |
Close
Hashes for sproto-0.1.1rc1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 510ad5f0050068e57af381e80975d908dffb2bc7fc205437442221a6fc3a13e0 |
|
MD5 | 9dd17fc9df3b1cfb2ace2209d925fa1c |
|
BLAKE2b-256 | 4b1f3978bf950b619ff39f2b9db1004db0a786db87d2adb0f48dff044e46ce32 |
Close
Hashes for sproto-0.1.1rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af0939b8b89a27fc9352aca8a42bb249902f95460eae588dc4a94da2d58ecc6a |
|
MD5 | 6040117fbe453b6685d9a9f62500e00f |
|
BLAKE2b-256 | a8800ed8879f87c09fc8a78ea011787e66b6f51f783297e8e4a84d0106a3b6c1 |
Close
Hashes for sproto-0.1.1rc1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca89250f680ea2a49436ddcc9d446c02f0b5d050e659cd42426ec62ca84abc3b |
|
MD5 | f92e53e7937ddf20f8ff553ecf8969ee |
|
BLAKE2b-256 | 1c7897451f35860bc1d9cd2f511d48fcf44d4e516c50c28ae00b0afce1e10f67 |
Close
Hashes for sproto-0.1.1rc1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbff5c0a1617cada177d3bf6079238b9239bd145b3a4ab847458d3cf7bd1db01 |
|
MD5 | d64b2be65b6a8703948e9b304188876d |
|
BLAKE2b-256 | a36639b8b1c5221a3f83518ac2b43f1ef11c1da3a2f7447718994e4b117a673c |
Close
Hashes for sproto-0.1.1rc1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c422e3de58a997d0362b6f1e73d05ff3f3a365260b07b1e04847747fcf2eb07f |
|
MD5 | c76a7395870c32fb54bfe7bdc7492669 |
|
BLAKE2b-256 | f7be47f79e40dbe2d1c367f7449ccf09cd0188a863d1aee2fc59baad1d096372 |
Close
Hashes for sproto-0.1.1rc1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbea0abff55dc855a6ee1be49c60a15072cbd51c3b57517df7ff9982cabba036 |
|
MD5 | 385f6acdd4d7429ac1c18d350d72d739 |
|
BLAKE2b-256 | 0f09afa6234598dd4b15232c0f39f268393cd19fa9678dc305cfbd2940e68b98 |
Close
Hashes for sproto-0.1.1rc1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 073f9450a309d41c5862b7a29195cfc434edbc18e08fe5961b9a2855bbf58e2a |
|
MD5 | 32603e35e0dfc9cffe3c5f0e84c535d4 |
|
BLAKE2b-256 | bc88c927d1510f4599475b37e540fb68c05231d8308f204c5cc87029fd04ab9f |
Close
Hashes for sproto-0.1.1rc1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6315091da37d28739fca45f6f0d5c5f3e042a42e746c89889879bed60211f704 |
|
MD5 | 7df88069187077ba928aa4c32bbca98b |
|
BLAKE2b-256 | 88484c988aebc8d9c8e5e432ad0cf421a361978f341569251b82f3bfd4dc223c |
Close
Hashes for sproto-0.1.1rc1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37f45a73a4db84d73c1bea19983197161bb9f29183267cdbdea74435b71c3625 |
|
MD5 | dae07d4ed388176ba4e14dd2f19251b2 |
|
BLAKE2b-256 | 6eb432726ff8a87442474e85a5cb53cbe6ef6cbf043e39469eb398166312f923 |
Close
Hashes for sproto-0.1.1rc1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea18ca04b48e3729e867bae72af35c38ac367d9f3ef30170cc4417945435edd9 |
|
MD5 | b637842fa49265d903ca01217f822fc9 |
|
BLAKE2b-256 | 037b3075600b626fdc141a9cdbebba6d2ff56a80cf7f83e7d6bf351c13beb77e |