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.0rc1.tar.gz
(142.1 kB
view hashes)
Built Distributions
Close
Hashes for sproto-0.1.0rc1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81ec6948c7d8e97fe763e19d95865ff21ef4511b838429ca643ba826de54dbd8 |
|
MD5 | 43ca757f6bbbd725fabbdbf2ad963d7b |
|
BLAKE2b-256 | 0f5d2d4914a70acc3e755b17720a5ed675eb71caf171c25830a25aeb2124ea1f |
Close
Hashes for sproto-0.1.0rc1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4805fedaf66f8f7dfc67b01112a1dd3e6d954b5bbd4daa0c510a9eb540d46d3 |
|
MD5 | d8c192b08739d9a4f29574dc804f8fb5 |
|
BLAKE2b-256 | c8ac7e37c1fb59688c34dfb91af6417127ea1043109036d82b5b1c7e31eef9a1 |
Close
Hashes for sproto-0.1.0rc1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 060db33fa91a22c815e1e7d20785e010960c76c6d27f5c7c514e1ae58bd6f43f |
|
MD5 | 40465aa209cd3eb4eeb274f085f40f3e |
|
BLAKE2b-256 | af03131f4d877cece35af390b61abab4baa5e425b23b0a50164bbf8c59396362 |
Close
Hashes for sproto-0.1.0rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e8625c55eee1b05e0693302ecf7eadc553b77fb0fc447157a9e1ebca5ee1769 |
|
MD5 | 3987bf26f15ab4af760ee8a24df8392d |
|
BLAKE2b-256 | 209a37a82247badd74aff468ddb99c1dea13fbcfe74fad8966415fc95ebf322d |
Close
Hashes for sproto-0.1.0rc1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44e1ae76358fc1483cce4a0a22905e1c9513809252f7e9073503d3ba8b9b673d |
|
MD5 | 3d31528623745c947b93b47c62314321 |
|
BLAKE2b-256 | 143b66f23185edc8baba20952b2db316eb578f969051322f42d0adc78ac26ddb |
Close
Hashes for sproto-0.1.0rc1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3553cda5ef37f28d28b789070e7837f0222e4975d9169304dafbc8d385284495 |
|
MD5 | cc51c15fc4bf1e9c17db83f23a4e81a6 |
|
BLAKE2b-256 | 25d34fed73dc8df61bfda10aa8e28daa51216383ad19e4259cc804f8435ebf0e |
Close
Hashes for sproto-0.1.0rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40274096b8b9bed7541b2dd8a0cb091c61fb3b76cc2c04d9da31a1cb3369c68d |
|
MD5 | 59dd22dac25c536dc58fef9fc3550ee0 |
|
BLAKE2b-256 | df5348a4360a84aa8f5a94d5804da5bbf45819540afc180e85e99cf3482b4d6a |
Close
Hashes for sproto-0.1.0rc1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12205fedb69112d9d1ec3537095f98cf4b9510e37ee10aaf075386932ef148cd |
|
MD5 | 80890cb66335158441d2cc863717aba2 |
|
BLAKE2b-256 | 68142e67f85815f401a4078b5a1f146cc5b3be252f4919c3e31744240bbd5725 |
Close
Hashes for sproto-0.1.0rc1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 309b9b3276d0427587a5b4f091dc877e58896513f096fcacef288d7d4c195c77 |
|
MD5 | 3e005f93e54020d9a6d0ce9db9dc22ec |
|
BLAKE2b-256 | 919106a546f6f98c06b26c9fcc8517a5f8a11599e0072b2e5b5a0973594eaf03 |
Close
Hashes for sproto-0.1.0rc1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b5cf1a5e86ea34e3956514490e498dec122f0852ace8a60a402e4d89170a36e |
|
MD5 | 8fdd8903c86c7a0a13b2caae785fa0a7 |
|
BLAKE2b-256 | 0a0de85be6b7cc1d288f2a3730ff4df9bc354e4ff107b746e440c52ceded9f92 |
Close
Hashes for sproto-0.1.0rc1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53912457f95d12b4365a6115072c7f64a45f83701ee5359020b61bc6f784663a |
|
MD5 | 499cd12408ae6165cb2a7e8c25d440ee |
|
BLAKE2b-256 | e7f702c1930ba6283677d7ebb9cb799d82a378e36d657e055bd19d8d08f0a194 |
Close
Hashes for sproto-0.1.0rc1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 830d36ad3776f556ab79303123ff83a8e1e8b45d04af28464abcad68803326ce |
|
MD5 | 8158a9cc706cba928121dc68a9ec203d |
|
BLAKE2b-256 | 9f00f8848910aef384ff2cc18778840db858c1c4c242c704f585e153b41893c9 |
Close
Hashes for sproto-0.1.0rc1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7262f656c6fed5340dc625a175ce9bf0ecc833b113e7baa9025cdf8a5095207 |
|
MD5 | 0a3d45070d36aecb0498c1ff7147fe2a |
|
BLAKE2b-256 | 411982a26b5cae9c69d8f2f1c058b60ad7f7b5b5817cbee3e4f8d5d0a532f9c6 |
Close
Hashes for sproto-0.1.0rc1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01c01cbc6a652665f2162a0499b438fd3b447648efa3b5fcac87b71736225390 |
|
MD5 | 0b5b0ed4eb1b0629848c8adaf6abc162 |
|
BLAKE2b-256 | a33ae808d66cc3ce992f29f4c369342c96cd7ae82daa516973d8b0179f7ef6a9 |
Close
Hashes for sproto-0.1.0rc1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e73462baa1cf040658707fe67f1d95d50fece521b1308c10c6a6f8e6bce0cf0d |
|
MD5 | d9cfcd45745ec91532a6bd5f0cb6d6c2 |
|
BLAKE2b-256 | 31a641d2eff12cc182528afea7417bde48fb5d23fd5acb5827a83a1778a948de |