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.1.tar.gz
(184.8 kB
view hashes)
Built Distributions
sproto-0.1.1-cp39-cp39-win_amd64.whl
(222.2 kB
view hashes)
sproto-0.1.1-cp38-cp38-win_amd64.whl
(222.3 kB
view hashes)
sproto-0.1.1-cp37-cp37m-win_amd64.whl
(220.9 kB
view hashes)
sproto-0.1.1-cp36-cp36m-win_amd64.whl
(220.9 kB
view hashes)
Close
Hashes for sproto-0.1.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 801fadd9c048466c00bfe7515177dcdffb9ed1526f9798962b339bfcff922199 |
|
MD5 | 33a46f6cc7929adc02b7904f6a342cc4 |
|
BLAKE2b-256 | 94eb073067dc25558f2540cfe9e215b994d88c5929f7b67bf1144223c237a662 |
Close
Hashes for sproto-0.1.1-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cca33700a4f2b6946eaaec594a09d4ed8ef0ef1d7a62b9b0440894b5331ece9 |
|
MD5 | a4628f52b0b8ac6240fc9cd3e39a2ccf |
|
BLAKE2b-256 | d109a1e51aa4d2a849bba2ebcb70a5c14cf83803ec38b06056d9ed5640b53fd2 |
Close
Hashes for sproto-0.1.1-cp312-cp312-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c7e96244ed138744f0f40b38115b2614812f12cb6a0f981841b1e9eece116c3 |
|
MD5 | cc992091e05332f3a881d6e592ac5261 |
|
BLAKE2b-256 | 8faa38ef8452ebabfd735d299694c5d4df7209fb6c96d17338df11dc3f211631 |
Close
Hashes for sproto-0.1.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b99eb08e28b64e6f32463c38dc93f824f524ea09c6ddfefd7db1eb6459941cb |
|
MD5 | d09f0e644a552cad2e1d57daef967153 |
|
BLAKE2b-256 | 0ddd4057ec1ca825d651e8a5f6f32f23eb123dcfe3d5c4511b0bf112757fd71a |
Close
Hashes for sproto-0.1.1-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbd532b764c903fb25d8b0abd03adc8ca30591c42dbf1ba24d33d19c9ffa4ec6 |
|
MD5 | 6c8c6ff13cc33a9319203ce5e6d08678 |
|
BLAKE2b-256 | 0ed79fc3fc1273188985bbd190ae6143281d5d328fdd62585d14b05083c7c411 |
Close
Hashes for sproto-0.1.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98cd34fc55d6bfec322d447ac6424b1eafd95d5d4b11af0387551a08c93fda1f |
|
MD5 | 6ad2e90c06deb24e22a2f60a793ff821 |
|
BLAKE2b-256 | 55d358bb8ab891e7d9c7f798c3fc5d32fce71eb8cd6a9eb46a49e2fe21244cf2 |
Close
Hashes for sproto-0.1.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b4dcc811ec104e29dfbfdf0d8053d2a98fec01f9f9eb4e98e4cb80698db6815 |
|
MD5 | a4b795f44f90a9c4994942ca31af1d7e |
|
BLAKE2b-256 | 6ee25f1fdb26b51f02237747c02d7867a51738fde1d772c2adffd3b1a0d2f9d7 |
Close
Hashes for sproto-0.1.1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75ddb4bba63ded0c37d893dd4ca605b4c75ab824ebbe412f81c79b1f9c342eef |
|
MD5 | af7ef7a6e4d0470f0c1a65f1cbad2428 |
|
BLAKE2b-256 | c6507a44c38bd9799375d5fe71a26972cd85fc4c9cf6620e353814c8c0caa8bd |
Close
Hashes for sproto-0.1.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cf477f909f8342b1d6b23706a5a25aadc01e65158219c328df906920430ccde |
|
MD5 | e2b0085c358baa20171020bfb8c1db61 |
|
BLAKE2b-256 | f3d204732e6e31b6e6c44beb740d518fb8a5ab7c1520d55c2693707c2a8b7478 |
Close
Hashes for sproto-0.1.1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7339dd3bc1982112b8eb92e1f0564b24049830726905a4248ab154be7ec15f72 |
|
MD5 | 292179b312a42ff5046eb251d86b1549 |
|
BLAKE2b-256 | ee15587b35c93c19befeb4014bc161db92600e1fe7e2d68d71128db5f45baf7a |
Close
Hashes for sproto-0.1.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22c99824d9283d38ae2a44f7ad417eb6e4a2aadbe1ae097d087c166d658cff26 |
|
MD5 | 6d9ed6d23da7479e09761147fc24c5b8 |
|
BLAKE2b-256 | a1960564b1a8d996f8270e410e62aaeab31c037e64e76557a35eb10069e69b73 |
Close
Hashes for sproto-0.1.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1940c103a43704ae7d4696f0dff94d524fa44b41c4076ca6d296c0cca808d34f |
|
MD5 | 86c219784360e66dbf78a7fcf194de9c |
|
BLAKE2b-256 | ba175c7f755b1cddf69dad6def24b7764603122fd14b5796de8cbf680c218983 |
Close
Hashes for sproto-0.1.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf1b6ba91af92644dacfc2d0669c10c0e5b573508095646e4cb703d8228a3592 |
|
MD5 | d864ed7576c493b95a8d4b718874c3b2 |
|
BLAKE2b-256 | b3490d2dba92c1f1a1f9d59f147a4109f6abf6d29365f6bb725ec978b5763a94 |
Close
Hashes for sproto-0.1.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0704c33ae16794db156571a9fdb9a6c1d695ed42fbdcb78e234352af997f40d |
|
MD5 | ac99f54e4a6d0096b3e446649d4e9087 |
|
BLAKE2b-256 | 283f4e08cfdc40a2844123ddacd0412a0e8ca83500e2502e8450368d2fc7be53 |
Close
Hashes for sproto-0.1.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97b4169bc9b6963a6be524d1de77aae14d79dd145e48727619d1618a0d104781 |
|
MD5 | faa373294d6b292ecb9eaef54df3b0b7 |
|
BLAKE2b-256 | b385f593f99b760f6cfc53c8a3002cf3cfb02838543e923bc08d60f18afc6133 |
Close
Hashes for sproto-0.1.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79ac68df441040767e72c2524c4232ef42c1f137feb01db64d416004e599b767 |
|
MD5 | 207eb4642566ea1f40ce8577a13c72d4 |
|
BLAKE2b-256 | c442463aed66267857ecd519016a8db6d8ea808b8f6ffcf235ced882e8cc7cce |
Close
Hashes for sproto-0.1.1-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0b674866497fda741446fb0c1a3b6245a73b0e6a37a86ec648ed4f80861ad0b |
|
MD5 | b8f86d4b40eac7b253d8a48429131b63 |
|
BLAKE2b-256 | 8b4de20e3131058a7f529b277e8286c00856edf81cd04027a255527a875457c0 |
Close
Hashes for sproto-0.1.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac8b4d49f8bd442b4c9d6cd5f1eb5f7842d5710fc4715efb61a99af1700e0a41 |
|
MD5 | 991b2f12e6edbf0dc8aa3be5cd55e906 |
|
BLAKE2b-256 | 3070e4313afea90e60ac243eac17ae65eab85a805fa067b382ac5548a6461ec8 |
Close
Hashes for sproto-0.1.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49513052fdbbf54caaf46ce4dfdc15164bf9b7f5e502bcddf72de5508af51341 |
|
MD5 | 98d6ef3b3a06dd56c68caa0df56a8bd3 |
|
BLAKE2b-256 | 5ebb40cc4e0dbc78ee2c6fa79fe2a184d2eef23616948706e04838f46e2bf57c |
Close
Hashes for sproto-0.1.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92ca00ae4e626706a1a74ca8679fe782ce65cfee5e9a3dca21784f895cc276f7 |
|
MD5 | 67f06d206adaa531b4c32048c19c968a |
|
BLAKE2b-256 | d4fbfa5b11630ac784d94a5de022064579aab4facd91f84ef145c0ae0b68fac7 |
Close
Hashes for sproto-0.1.1-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b7700f6ca830b3350fefe73a9d7b70724aca3147433839e63a354216211b76b |
|
MD5 | aab64feafa8af5a2bb3bb95198601b75 |
|
BLAKE2b-256 | b5989adb75c85a1e9631110b70862b1d8ef9d501bc0825bc8232a9d04c15bd0c |
Close
Hashes for sproto-0.1.1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61be7627abe6c011bf3435c7f8171ef8abcaed9b84c8c32e633abcb6176baa1a |
|
MD5 | dd27a826ac3188a24678763e7459983f |
|
BLAKE2b-256 | 9cbe1d7339dd3cda8ab43bc08922fb08000394820c402f34f0cf50db8a0ee0de |
Close
Hashes for sproto-0.1.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66c0af669d8c6c1d94331174a12f603a96f4eaf07ec2f72a4d5ccb00ef5cec71 |
|
MD5 | 62b087d51cda08a3d16a7f68a2164eab |
|
BLAKE2b-256 | 674510db81f158368904d36d949fe750c0154063591e70323743b6f1f99096a2 |
Close
Hashes for sproto-0.1.1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ca733b62eef822596fa9690775b323c24a2cd7ee8400b4d47adc58797a785bb |
|
MD5 | ab4568d343a88759b64a340db79dbf0b |
|
BLAKE2b-256 | e4a3500cbb322288143e2d8822fe7bdd310bd3fc0016933d05df6e5ff64c858e |
Close
Hashes for sproto-0.1.1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | baac7f63096c05b30586793ab4c50034ecdc351dbe4a11cb53bbedb5b6ec70fe |
|
MD5 | 33b970ccee7935dde1cd1b4cfd27161f |
|
BLAKE2b-256 | 132f616c1da0fa3c4a2d2770c5c9ee7911a5a1bafff069b75a38a19af6527227 |