No project description provided
Project description
Length-Delimited Proto
When protobuf messages are either across the wire, or put in intermediary storage, it is helpful to be able to read and write individual messages in a streaming format.
This package exposes two methods:
write_ld(writer, protomsg)- writes one instance of a protobuf message to the streamread_ld(reader, msgtype) -> protomsg- reads one protobuf message from the stream, using the type as the constructor
This package uses an unsigned 32-bit integer as the length-prefix.
Example
Assuming there is a protobuf message with the type name "User"
from ldproto import read_ld, write_ld
import myproto as pb
# .ld is for length-delimited
with open('out.user.ld', 'wb') as f:
for user in users:
write_ld(f, user)
pb_users = []
with open('out.user.ld', 'rb') as f:
for pb_user in read_ld(f, pb.User):
pb_users.append(user)
To write to / from a bytestream in-memory, use BytesIO in-place of the files in the example.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ldproto-0.1.12.tar.gz.
File metadata
- Download URL: ldproto-0.1.12.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.3 Darwin/19.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7645669c4d53091694a06cadc75ca9241377146d7339f93cb122c68e7c1e7c13
|
|
| MD5 |
16f310a1069fe8779ab0ed5da75bed3c
|
|
| BLAKE2b-256 |
75c13bc671bca67d9d31772ef1f33f2ada2082545708f129b1ceb8e9269284bb
|
File details
Details for the file ldproto-0.1.12-py3-none-any.whl.
File metadata
- Download URL: ldproto-0.1.12-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.3 Darwin/19.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43a553dcd4f11b33b8e7aef03df590015193c8f656aa41944c34eab1a9953158
|
|
| MD5 |
b807d8cc65c6472ffa02914c05f211c2
|
|
| BLAKE2b-256 |
fc4f934f35238f5e86d53bbb9baddcee15612cccf8010cfb26bea448f3acc913
|