sproto encode and decode
Project description
✨ Pysproto ✨
Another Pythonic Sproto Python binding for sproto
Powered by cython, high performance, pythonic
Usage
- 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.0.tar.gz
(185.8 kB
view hashes)
Built Distributions
sproto-0.1.0-cp39-cp39-win_amd64.whl
(222.6 kB
view hashes)
sproto-0.1.0-cp38-cp38-win_amd64.whl
(222.6 kB
view hashes)
sproto-0.1.0-cp37-cp37m-win_amd64.whl
(221.3 kB
view hashes)
sproto-0.1.0-cp36-cp36m-win_amd64.whl
(221.3 kB
view hashes)
Close
Hashes for sproto-0.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf93dfb04e00ea9636bd3576304035f163798b54425ba600a16d3956e1aeef0d |
|
MD5 | dcd731deb8b4a2ea78718526d01d11c5 |
|
BLAKE2b-256 | 0300164839fa1fc70a04bea6b81cb2cc7c224388ab3c05527f9f90675cb5ab42 |
Close
Hashes for sproto-0.1.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f266f6096a54b2c513b27d5ec0821bda5c17ae6cf7e34884d2541e0f6f08e2aa |
|
MD5 | c74e05731431119ae37e92d2e286e514 |
|
BLAKE2b-256 | 69b145cb06b4aa5fd7a5a9036cca04d2d2fbce9b3e5424e1a8365b663ac3ca39 |
Close
Hashes for sproto-0.1.0-cp310-cp310-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffd7de4b20945330904a932c3b5b67d627e08b5fdd081fa8d1f4637d6e65d0f1 |
|
MD5 | da449525355a906cc89a64bc0c0a613c |
|
BLAKE2b-256 | 744dd547d49a7b278332aaace07831afe0d73b2ffd81007d710cb6d6622077f9 |
Close
Hashes for sproto-0.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8bffdd29fbb78121be85e35e31c38cb4ebdfa694c790363cee2ac4f70564217 |
|
MD5 | 7a4bbbece24267fbecdee157316415b7 |
|
BLAKE2b-256 | ecff095db0af2660e0662399798c8eb9fce0b884a7c347954a1aeb22b09cc2b3 |
Close
Hashes for sproto-0.1.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea85615a177a4a6959610d14fafd077e1eb32c1ea41f32fece84263df64781cc |
|
MD5 | fbd744581c2a2571e3506a932ab16105 |
|
BLAKE2b-256 | 86a1ee5c5ecba9e9e2d484ea7db7a470005cfe2084bf63cb12b2f8571342028e |
Close
Hashes for sproto-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08fc86d398b37511fd601ffe6807ad8b4ba27d6b6e6607646d035f640b3874d0 |
|
MD5 | e66fce94515ad4e70222249063da7dd5 |
|
BLAKE2b-256 | 09f758e6b9e646b80e8d6af7533cdd788902962b1df6a3d58b54b1787b431ca7 |
Close
Hashes for sproto-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48862f4881b4f144466b1d0da6383e104f4e0b61014a49b39a779aad5ccf2fce |
|
MD5 | 4ea796b624f9b05c1b2b2719cf893a15 |
|
BLAKE2b-256 | 07d740904f8a3d01e4419b6dd451d62c79392ba550a31d69b5e43a7b997f9e50 |
Close
Hashes for sproto-0.1.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee4d1c5f9c415c03ff9db09c32b8a15fa7755011dd389594347d965485517354 |
|
MD5 | 0fcc37c88a3333334e6c00cc19ae084c |
|
BLAKE2b-256 | 4c01a57fd16c73338b743a300d60b61fd46cb2132e8f5e4d17b331b6c91647c0 |
Close
Hashes for sproto-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4522108b824708e124a4188e8b7af062f581c0ca1e306e9a4054309ea8a8708e |
|
MD5 | f43f7d85697be01c0ccb8cff83176b4c |
|
BLAKE2b-256 | c08d446bc68e034b63df90fb9aeb3a798c6f2e44d9711d2ab982a635fa9c40ca |
Close
Hashes for sproto-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37947d6823b227fbc49ce8ab93244b093b5d9c786cb25f7b546d52a5f41aab9b |
|
MD5 | 6351067da6018e8a3c2893b3cd85867a |
|
BLAKE2b-256 | 7994989c045a251c62e27c31b032d41ee3e2a70801009c21fd3453d3761f6cad |
Close
Hashes for sproto-0.1.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c53a3e883994e9cab59b1dc9c39d09c4e7891a84d09b2f350f62a648779b124 |
|
MD5 | c90f3cc5c620252d274e6ec47bf439d7 |
|
BLAKE2b-256 | 143a2f3679a935c0ed92b54edf6283bbf02a1bfa001630caa76cfe585325e121 |
Close
Hashes for sproto-0.1.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0594120149ffdcc6c09d2778ba0e64848cee6da2d1fc922338586e8eb0a41bb5 |
|
MD5 | 08141ce8519fdf444da891369c16f660 |
|
BLAKE2b-256 | 5ea9b50cbbc2c584f75f220b84cde691e05c71249deed25bee6c7e127e988fb9 |
Close
Hashes for sproto-0.1.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 649c5c6c90bfc528fcc04bff1bed29e6d2f1803016f79905ad33db09f0bd96c3 |
|
MD5 | ce5c9a42baf0922de3e516056697cf3c |
|
BLAKE2b-256 | 52ac6b48a0a3a60f9e902a53844621b1a8c019c084bd484f11e3f28a30366fef |
Close
Hashes for sproto-0.1.0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e11d3c5e371c6755979b9f76b6bb47f93b7fdb0645dc41ca60d3ea54a0f4058a |
|
MD5 | a2c10528336d88fd48da5b4a799b1399 |
|
BLAKE2b-256 | c6fec5c3f7779d2aa46f785cc1c34dd140ba1f746c37164e71b0bda657b47c3d |
Close
Hashes for sproto-0.1.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8e7b21eca2ae1eb06f8fbc19af03ad6b7e8caad54eaee581f326dc2a5fc4904 |
|
MD5 | 41eb7ae3704b7ca909171419fc009e40 |
|
BLAKE2b-256 | 81535b88cc25efa02e13be5a54bffb27d7cf19a46d509f1f9b3db47d6797e550 |