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.2.tar.gz
(209.0 kB
view hashes)
Built Distributions
sproto-0.1.2-cp39-cp39-win_amd64.whl
(275.5 kB
view hashes)
sproto-0.1.2-cp38-cp38-win_amd64.whl
(275.8 kB
view hashes)
Close
Hashes for sproto-0.1.2-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e105585e5e0adda720316578e2684aea4971dcbb7b3d20c0439dfa9969d5f1fe |
|
MD5 | 1e7880e2e3b299a85103f45d02cdbf7c |
|
BLAKE2b-256 | 9d74cc6a63b33e65f847ee0cc6fbf3faa75cb2a72fdbd6e160c6ba4fb3ff42c5 |
Close
Hashes for sproto-0.1.2-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cd6e6830e19b45f99b588f6c0dfab9bb2f78d20bf4b305f21fbff91b386e403 |
|
MD5 | a638967206b7fbf44f01a319dbea7e11 |
|
BLAKE2b-256 | 1bd3200255ea5170d6e77cd90eca8a0c354370def9a50dc3cfe14a33cb58e41e |
Close
Hashes for sproto-0.1.2-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 020e4819bdc05a6df95134b2b24b50096acddbb23ce202d867af23ee79afeaeb |
|
MD5 | 738fc3b670a96d94b96c4950d98083ce |
|
BLAKE2b-256 | 06d836d648f4e8eece73d28f0054445249a5bb56271f4106882143cb280721e1 |
Close
Hashes for sproto-0.1.2-cp312-cp312-macosx_10_9_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 431004a748fc2a34bd297241a8a8979bc87e192e1243ce0ed96b15fff50cc07b |
|
MD5 | aed5ff96968cda70dbc3f4930c4ca7c1 |
|
BLAKE2b-256 | 94f5a16b6e843f258b9ce288f785955eee1371daae940f3ca5bf17a19838fc8d |
Close
Hashes for sproto-0.1.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc666382cee8d720c04c297e16c0fa915c1129e8bdfff922ee88639483c0f2b8 |
|
MD5 | be2a62b77b960cf68c1602c9548a06df |
|
BLAKE2b-256 | 06974050a12fb4b9521e0c882ec74be096b0ba376293c4b316ecf41b223a8d80 |
Close
Hashes for sproto-0.1.2-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71e63b09bb801060636f575d74f9d3f2fc683dfa8c1e34c4f4cedbe1a33de697 |
|
MD5 | f3a300c330640328f6fe45829a8c4ebd |
|
BLAKE2b-256 | b3fc410738b91a8d2346554c11d4d37a21264ee4cf73cc592554be361ed1a189 |
Close
Hashes for sproto-0.1.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c889b2cab9370ff1ceff6c50ac70d5950363a450c61dfc2e032a7339ef20561 |
|
MD5 | 8f72fef32ca327d49d241fabbe43e2b3 |
|
BLAKE2b-256 | 374ae910d1ce0daf95b3f71b2c8330eb4056176b4a2669f00ea441b704ae8120 |
Close
Hashes for sproto-0.1.2-cp311-cp311-macosx_10_9_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dfe21a92ec3ae8f376b0fc999e6db25a53a6c12084df7c46b810dfabea18ccc |
|
MD5 | 35749053d7a7c75ab28906f1a2ad941b |
|
BLAKE2b-256 | 9490da6d0f090d25d605c23c63dfc90f842f360880ba5ce2c9e8644c3183db10 |
Close
Hashes for sproto-0.1.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c81c298489443815d2b92a7eef67c094332b9a109e0f51d6d365a5090ab21f3 |
|
MD5 | c597e38f2bfbf3366c5cd45cfee837fe |
|
BLAKE2b-256 | 80a6d057e69df00dc292fc7191f6d17a3df9cfe947093b04fea9e9328cf48172 |
Close
Hashes for sproto-0.1.2-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c0bea2b62d5df2fa8c43d644a8c3dc4c370626e086cff459d4dd57a5695a047 |
|
MD5 | cc13b4e8641217ebc4d87611e6cfd3a1 |
|
BLAKE2b-256 | 518a9eedd0da8ff5ef0bfc7a56a9070b470fe37753e77dc6106cb11fd96ace50 |
Close
Hashes for sproto-0.1.2-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86d20f664be3c1f29bbc25dacc06b4f12851922bcc38b7bc4516263d854b41f9 |
|
MD5 | f95dbb0c7249acc93936f8d64b84673b |
|
BLAKE2b-256 | 79bf5a056e7a4a8af8b376c519371be3081e3b698af71a2326f881b63906a102 |
Close
Hashes for sproto-0.1.2-cp310-cp310-macosx_10_9_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e92bffdb05cfeadf46bef4a72490d32579426e99886c8328d0bf08663f5fb189 |
|
MD5 | ebe41771a2b644d5ef60c9fb6872654a |
|
BLAKE2b-256 | 46e4462cf85a53b87c425056b440639c10d43977eda3f7bb1e6210da7d19cb39 |
Close
Hashes for sproto-0.1.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92d2cd076c9afc7ab232056c225a17b046b7b86ac590089f33ae174e60f94441 |
|
MD5 | 8c4b2157f76152640438535fe9c3a43e |
|
BLAKE2b-256 | 4090a6f05bc315f7a7cf9872a12eaf7fc791ef3901afb20200eec4318501ecfb |
Close
Hashes for sproto-0.1.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94516b310db1b32f42559423257fa73a52ee7ca7619290da65ab90838e6da678 |
|
MD5 | 4b181e65935da3d3f9a46fc95a84bc91 |
|
BLAKE2b-256 | 55a9dce12669c4a7f840109ef737650281b750451128e5a9e0f5a4c7b067d2ea |
Close
Hashes for sproto-0.1.2-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da1f057b8767c6912249cdd86ef1d054c717485e69fda08f254cca5a5a4c3df6 |
|
MD5 | 964f2068cb1300fa5cf9929d95a54203 |
|
BLAKE2b-256 | f86217fc73654d723506fcbdaff37931e4168483617d5300966e93846cd95b49 |
Close
Hashes for sproto-0.1.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78878945453bd7c7c385f1c10901a2ad9a21f0fdbc092aaad6eaf89054d8cd2b |
|
MD5 | 624543fc99440215c7b7b6be9ace9d59 |
|
BLAKE2b-256 | 805c5be8e843d836ddbf0391c9588414dec08b4365dcbc30e5c794b686f0f7bc |
Close
Hashes for sproto-0.1.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4ad41eb2699c3fdb6ef5717f1cb7b3527e9891cf0dd71988102f50190fbed80 |
|
MD5 | 99b19893266ef38e3de5a01d47d6c484 |
|
BLAKE2b-256 | e68fcd9f4f102e046e94d827166618941a3349ca502eb2e4e20c4c0db20c649b |
Close
Hashes for sproto-0.1.2-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e58a31bac454798550374eda9c75529e583985be7d4d5b1088f8ef84f346fde |
|
MD5 | ca1d05bcf3b055b8144879e83b26a62c |
|
BLAKE2b-256 | 3957052691b13b984ba1ee5d588977b7bd8a0c2e93aca08f19386efddc5d3d13 |