A lightweight binary protocol serialization library like ProtoDef but in Python.
Project description
PyProtoDef
PyProtoDef is a Python package for defining and handling binary protocols, inspired by ProtoDef.
Features
✅ Compact binary serialization
✅ Faster parsing than JSON
✅ Strong data typing (int, float, string)
✅ Ideal for networking, gaming, and IoT
Installation
pip install pyprotodef
## Usage Example
To try out PyProtoDef, create a new file (for example, example.py) with the following content:
```python
from pyprotodef import ProtoDef
# Define a schema
schema = {
"name": "player_data",
"fields": [
{"name": "id", "type": "int"},
{"name": "score", "type": "float"},
{"name": "nickname", "type": "string"}
]
}
# Create a ProtoDef instance
proto = ProtoDef(schema)
# Serialize data
data = {"id": 123, "score": 99.5, "nickname": "PlayerOne"}
binary_data = proto.serialize(data)
# Deserialize data
parsed_data = proto.deserialize(binary_data)
print("Serialized:", binary_data)
print("Deserialized:", parsed_data)
Then, run the example with:
python example.py
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 pyprotodef-0.1.0.tar.gz.
File metadata
- Download URL: pyprotodef-0.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7479da43b24b495575e4dbcfd3dac95ccdb18f34068dc691eb0a6f71d211e745
|
|
| MD5 |
9929fa8ec71afc871c5c3ed2d608c96a
|
|
| BLAKE2b-256 |
2171cb91844ef6a838f4ed2b0d72a61a6d0cb0b93c547315b58008be52a26d5f
|
File details
Details for the file pyprotodef-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyprotodef-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fc9aedf28103bc83d49161f70de5ea76d14cb9d656e6a4cf4830889dd1618a9
|
|
| MD5 |
d3420d7d758030343f822fc56e6cf0bf
|
|
| BLAKE2b-256 |
6f97a38eb7554a20c7f154ce5080e6d772200a01ecc4aec6685cb8667087ab8b
|