pd-proto 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pd_proto-0.9.0/.github/workflows/python_tests.yml +40 -0
- pd_proto-0.9.0/.gitignore +75 -0
- pd_proto-0.9.0/.gitverse/workflows/python_tests.yml +55 -0
- pd_proto-0.9.0/Cargo.lock +248 -0
- pd_proto-0.9.0/Cargo.toml +15 -0
- pd_proto-0.9.0/LICENSE +19 -0
- pd_proto-0.9.0/PKG-INFO +128 -0
- pd_proto-0.9.0/README.md +103 -0
- pd_proto-0.9.0/SPECIFICATION.md +242 -0
- pd_proto-0.9.0/img/1.png +0 -0
- pd_proto-0.9.0/img/2.png +0 -0
- pd_proto-0.9.0/img/3.png +0 -0
- pd_proto-0.9.0/img/4.png +0 -0
- pd_proto-0.9.0/pd_proto/__init__.py +12 -0
- pd_proto-0.9.0/pd_proto/const.py +108 -0
- pd_proto-0.9.0/pd_proto/dump.py +37 -0
- pd_proto-0.9.0/pd_proto/errors.py +72 -0
- pd_proto-0.9.0/pd_proto/load.py +55 -0
- pd_proto-0.9.0/pd_proto/pd_proto.pyi +62 -0
- pd_proto-0.9.0/pd_proto/py.typed +0 -0
- pd_proto-0.9.0/pylint.toml +537 -0
- pd_proto-0.9.0/pyproject.toml +40 -0
- pd_proto-0.9.0/src/constants.rs +269 -0
- pd_proto-0.9.0/src/dec.rs +748 -0
- pd_proto-0.9.0/src/enc.rs +388 -0
- pd_proto-0.9.0/src/lib.rs +67 -0
- pd_proto-0.9.0/src/options.rs +306 -0
- pd_proto-0.9.0/src/utils.rs +46 -0
- pd_proto-0.9.0/tests/compare.py +64 -0
- pd_proto-0.9.0/tests/compare_json.py +28 -0
- pd_proto-0.9.0/tests/example.py +7 -0
- pd_proto-0.9.0/tests/test_dumps.py +119 -0
- pd_proto-0.9.0/tests/test_loads.py +139 -0
- pd_proto-0.9.0/tests/test_use_cases.py +196 -0
- pd_proto-0.9.0/tests/tmp.py +53 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Python tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "master" ]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
tests_maturin:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
container:
|
|
17
|
+
image: python:3.12-slim
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Install Rust and Run Tests
|
|
24
|
+
shell: bash
|
|
25
|
+
run: |
|
|
26
|
+
apt-get update && apt-get install -y curl build-essential cmake
|
|
27
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
28
|
+
. "$HOME/.cargo/env"
|
|
29
|
+
export PATH="$HOME/.cargo/bin:$PATH"
|
|
30
|
+
pip install pylint maturin
|
|
31
|
+
cargo check
|
|
32
|
+
cargo test --verbose
|
|
33
|
+
python3 -m pylint --rcfile pylint.toml .
|
|
34
|
+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
35
|
+
python3 -m venv .venv
|
|
36
|
+
source .venv/bin/activate
|
|
37
|
+
maturin develop --release -- -C target-cpu=native
|
|
38
|
+
python3 -m unittest discover -s tests
|
|
39
|
+
python3 ./tests/compare.py
|
|
40
|
+
python3 ./tests/compare_json.py
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/.idea/
|
|
2
|
+
/.venv/
|
|
3
|
+
/target
|
|
4
|
+
|
|
5
|
+
# Byte-compiled / optimized / DLL files
|
|
6
|
+
__pycache__/
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
|
|
10
|
+
# C extensions
|
|
11
|
+
*.so
|
|
12
|
+
*.pdb
|
|
13
|
+
|
|
14
|
+
# Distribution / packaging
|
|
15
|
+
.Python
|
|
16
|
+
.venv/
|
|
17
|
+
env/
|
|
18
|
+
bin/
|
|
19
|
+
build/
|
|
20
|
+
develop-eggs/
|
|
21
|
+
dist/
|
|
22
|
+
eggs/
|
|
23
|
+
lib/
|
|
24
|
+
lib64/
|
|
25
|
+
parts/
|
|
26
|
+
sdist/
|
|
27
|
+
var/
|
|
28
|
+
include/
|
|
29
|
+
man/
|
|
30
|
+
venv/
|
|
31
|
+
*.egg-info/
|
|
32
|
+
.installed.cfg
|
|
33
|
+
*.egg
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
pip-selfcheck.json
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.coverage
|
|
44
|
+
.cache
|
|
45
|
+
nosetests.xml
|
|
46
|
+
coverage.xml
|
|
47
|
+
|
|
48
|
+
# Translations
|
|
49
|
+
*.mo
|
|
50
|
+
|
|
51
|
+
# Mr Developer
|
|
52
|
+
.mr.developer.cfg
|
|
53
|
+
.project
|
|
54
|
+
.pydevproject
|
|
55
|
+
|
|
56
|
+
# Rope
|
|
57
|
+
.ropeproject
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
*.pot
|
|
62
|
+
|
|
63
|
+
.DS_Store
|
|
64
|
+
|
|
65
|
+
# Sphinx documentation
|
|
66
|
+
docs/_build/
|
|
67
|
+
|
|
68
|
+
# PyCharm
|
|
69
|
+
.idea/
|
|
70
|
+
|
|
71
|
+
# VSCode
|
|
72
|
+
.vscode/
|
|
73
|
+
|
|
74
|
+
# Pyenv
|
|
75
|
+
.python-version
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: Python CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "master" ]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout repository
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Setup Python
|
|
21
|
+
uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: '3.12'
|
|
24
|
+
|
|
25
|
+
- name: Update Libs
|
|
26
|
+
run: apt-get update && apt-get install -y curl build-essential cmake
|
|
27
|
+
|
|
28
|
+
- name: Install Rust
|
|
29
|
+
run: |
|
|
30
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
31
|
+
. "$HOME/.cargo/env"
|
|
32
|
+
export PATH="$HOME/.cargo/bin:$PATH"
|
|
33
|
+
|
|
34
|
+
- name: Install dependencies
|
|
35
|
+
run: pip install pylint maturin
|
|
36
|
+
|
|
37
|
+
- name: Run Rust tests
|
|
38
|
+
run: |
|
|
39
|
+
export PATH="$HOME/.cargo/bin:$PATH"
|
|
40
|
+
cargo check
|
|
41
|
+
cargo test --verbose
|
|
42
|
+
|
|
43
|
+
- name: Lint
|
|
44
|
+
run: python3 -m pylint --rcfile pylint.toml .
|
|
45
|
+
|
|
46
|
+
- name: Run Python tests
|
|
47
|
+
run: |
|
|
48
|
+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
49
|
+
export PATH="$HOME/.cargo/bin:$PATH"
|
|
50
|
+
python3 -m venv .venv
|
|
51
|
+
source .venv/bin/activate
|
|
52
|
+
maturin develop --release -- -C target-cpu=native
|
|
53
|
+
python3 -m unittest discover -s tests
|
|
54
|
+
python3 ./tests/compare.py
|
|
55
|
+
python3 ./tests/compare_json.py
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "adler2"
|
|
7
|
+
version = "2.0.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "cc"
|
|
13
|
+
version = "1.4.6"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "a3eb0f42d6c360dc3f8a821f6bf2fdea7f72bfd36b3076eb0e6d1e9e0752fff4"
|
|
16
|
+
dependencies = [
|
|
17
|
+
"find-msvc-tools",
|
|
18
|
+
"shlex",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[[package]]
|
|
22
|
+
name = "cfg-if"
|
|
23
|
+
version = "1.0.4"
|
|
24
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
25
|
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
26
|
+
|
|
27
|
+
[[package]]
|
|
28
|
+
name = "cmake"
|
|
29
|
+
version = "0.1.58"
|
|
30
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
31
|
+
checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678"
|
|
32
|
+
dependencies = [
|
|
33
|
+
"cc",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "crc32fast"
|
|
38
|
+
version = "1.5.2"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"
|
|
41
|
+
dependencies = [
|
|
42
|
+
"cfg-if",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "find-msvc-tools"
|
|
47
|
+
version = "0.1.12"
|
|
48
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
49
|
+
checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d"
|
|
50
|
+
|
|
51
|
+
[[package]]
|
|
52
|
+
name = "flate2"
|
|
53
|
+
version = "1.1.10"
|
|
54
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
55
|
+
checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb"
|
|
56
|
+
dependencies = [
|
|
57
|
+
"crc32fast",
|
|
58
|
+
"libz-ng-sys",
|
|
59
|
+
"miniz_oxide",
|
|
60
|
+
"zlib-rs",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[[package]]
|
|
64
|
+
name = "heck"
|
|
65
|
+
version = "0.5.0"
|
|
66
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
67
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
68
|
+
|
|
69
|
+
[[package]]
|
|
70
|
+
name = "libc"
|
|
71
|
+
version = "0.2.189"
|
|
72
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
73
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
74
|
+
|
|
75
|
+
[[package]]
|
|
76
|
+
name = "libmimalloc-sys"
|
|
77
|
+
version = "0.1.49"
|
|
78
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
79
|
+
checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9"
|
|
80
|
+
dependencies = [
|
|
81
|
+
"cc",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[[package]]
|
|
85
|
+
name = "libz-ng-sys"
|
|
86
|
+
version = "1.1.29"
|
|
87
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
88
|
+
checksum = "879917b256f6317769b9f374b435805a8697013098aacce5a38ac106cd6a9469"
|
|
89
|
+
dependencies = [
|
|
90
|
+
"cmake",
|
|
91
|
+
"libc",
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
[[package]]
|
|
95
|
+
name = "mimalloc"
|
|
96
|
+
version = "0.1.52"
|
|
97
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
98
|
+
checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862"
|
|
99
|
+
dependencies = [
|
|
100
|
+
"libmimalloc-sys",
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
[[package]]
|
|
104
|
+
name = "miniz_oxide"
|
|
105
|
+
version = "0.9.1"
|
|
106
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
107
|
+
checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
|
|
108
|
+
dependencies = [
|
|
109
|
+
"adler2",
|
|
110
|
+
"simd-adler32",
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
[[package]]
|
|
114
|
+
name = "once_cell"
|
|
115
|
+
version = "1.21.4"
|
|
116
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
117
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
118
|
+
|
|
119
|
+
[[package]]
|
|
120
|
+
name = "pd_proto"
|
|
121
|
+
version = "0.4.2"
|
|
122
|
+
dependencies = [
|
|
123
|
+
"flate2",
|
|
124
|
+
"mimalloc",
|
|
125
|
+
"pyo3",
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
[[package]]
|
|
129
|
+
name = "portable-atomic"
|
|
130
|
+
version = "1.15.0"
|
|
131
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
132
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
133
|
+
|
|
134
|
+
[[package]]
|
|
135
|
+
name = "proc-macro2"
|
|
136
|
+
version = "1.0.107"
|
|
137
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
138
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
139
|
+
dependencies = [
|
|
140
|
+
"unicode-ident",
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
[[package]]
|
|
144
|
+
name = "pyo3"
|
|
145
|
+
version = "0.29.2"
|
|
146
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
147
|
+
checksum = "4688ddedf473e32662b9b067670129a8afb8c18e351482c70d62ba4a88171e8b"
|
|
148
|
+
dependencies = [
|
|
149
|
+
"libc",
|
|
150
|
+
"once_cell",
|
|
151
|
+
"portable-atomic",
|
|
152
|
+
"pyo3-build-config",
|
|
153
|
+
"pyo3-ffi",
|
|
154
|
+
"pyo3-macros",
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
[[package]]
|
|
158
|
+
name = "pyo3-build-config"
|
|
159
|
+
version = "0.29.2"
|
|
160
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
161
|
+
checksum = "f41027e41b4bd03f6e60f9f417fe24a6341a6bb744edd62b6f709f2a52ea30e9"
|
|
162
|
+
dependencies = [
|
|
163
|
+
"target-lexicon",
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
[[package]]
|
|
167
|
+
name = "pyo3-ffi"
|
|
168
|
+
version = "0.29.2"
|
|
169
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
170
|
+
checksum = "e591a95526fead067432c3b3a33fc74770b87b1e04e73671090d9c2055a2b327"
|
|
171
|
+
dependencies = [
|
|
172
|
+
"libc",
|
|
173
|
+
"pyo3-build-config",
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
[[package]]
|
|
177
|
+
name = "pyo3-macros"
|
|
178
|
+
version = "0.29.2"
|
|
179
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
180
|
+
checksum = "73225868fc1cd84eef2c3c230ddb91273bf1de46aeb8a4248da76d32a0924a1c"
|
|
181
|
+
dependencies = [
|
|
182
|
+
"proc-macro2",
|
|
183
|
+
"pyo3-macros-backend",
|
|
184
|
+
"quote",
|
|
185
|
+
"syn",
|
|
186
|
+
]
|
|
187
|
+
|
|
188
|
+
[[package]]
|
|
189
|
+
name = "pyo3-macros-backend"
|
|
190
|
+
version = "0.29.2"
|
|
191
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
192
|
+
checksum = "571575aa3749fa6216757dd47d2a3e7ef360f329a40f0666a9fbd14889024952"
|
|
193
|
+
dependencies = [
|
|
194
|
+
"heck",
|
|
195
|
+
"proc-macro2",
|
|
196
|
+
"quote",
|
|
197
|
+
"syn",
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
[[package]]
|
|
201
|
+
name = "quote"
|
|
202
|
+
version = "1.0.47"
|
|
203
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
204
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
205
|
+
dependencies = [
|
|
206
|
+
"proc-macro2",
|
|
207
|
+
]
|
|
208
|
+
|
|
209
|
+
[[package]]
|
|
210
|
+
name = "shlex"
|
|
211
|
+
version = "2.0.1"
|
|
212
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
213
|
+
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
|
214
|
+
|
|
215
|
+
[[package]]
|
|
216
|
+
name = "simd-adler32"
|
|
217
|
+
version = "0.3.10"
|
|
218
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
219
|
+
checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
|
|
220
|
+
|
|
221
|
+
[[package]]
|
|
222
|
+
name = "syn"
|
|
223
|
+
version = "2.0.119"
|
|
224
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
225
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
226
|
+
dependencies = [
|
|
227
|
+
"proc-macro2",
|
|
228
|
+
"quote",
|
|
229
|
+
"unicode-ident",
|
|
230
|
+
]
|
|
231
|
+
|
|
232
|
+
[[package]]
|
|
233
|
+
name = "target-lexicon"
|
|
234
|
+
version = "0.13.5"
|
|
235
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
236
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
237
|
+
|
|
238
|
+
[[package]]
|
|
239
|
+
name = "unicode-ident"
|
|
240
|
+
version = "1.0.24"
|
|
241
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
242
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
243
|
+
|
|
244
|
+
[[package]]
|
|
245
|
+
name = "zlib-rs"
|
|
246
|
+
version = "0.6.7"
|
|
247
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
248
|
+
checksum = "34b31d188d9d685a4f9c7b46d6e36631b07058d2cfe190267adce54dc230bf12"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "pd_proto"
|
|
3
|
+
version = "0.4.2"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
|
|
7
|
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
8
|
+
[lib]
|
|
9
|
+
name = "pd_proto"
|
|
10
|
+
crate-type = ["cdylib"]
|
|
11
|
+
|
|
12
|
+
[dependencies]
|
|
13
|
+
flate2 = { version = "1.1.10", features = ["zlib-ng"] }
|
|
14
|
+
pyo3 = "0.29.2"
|
|
15
|
+
mimalloc = "0.1.52"
|
pd_proto-0.9.0/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
PDProto Dual License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, kotolex. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software is licensed under a dual-licensing model:
|
|
6
|
+
|
|
7
|
+
1. OPEN SOURCE / NON-COMMERCIAL USE (AGPL-3.0)
|
|
8
|
+
For open-source projects, educational use, and non-commercial development,
|
|
9
|
+
this software is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
|
|
10
|
+
You may use, modify, and distribute it for free, provided that any derivative work
|
|
11
|
+
or service using this software is also fully open-sourced under the AGPL-3.0.
|
|
12
|
+
|
|
13
|
+
2. COMMERCIAL USE / PROPRIETARY LICENSE
|
|
14
|
+
If you wish to use this software in closed-source commercial applications,
|
|
15
|
+
commercial SaaS platforms, corporate internal tools, or for any revenue-generating
|
|
16
|
+
activities where you cannot open-source your entire project under AGPL-3.0,
|
|
17
|
+
YOU MUST PURCHASE A COMMERCIAL LICENSE.
|
|
18
|
+
|
|
19
|
+
To obtain a commercial license, please contact the author at: farofwell@gmail.com / https://github.com/kotolex
|
pd_proto-0.9.0/PKG-INFO
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pd_proto
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Classifier: Intended Audience :: Developers
|
|
5
|
+
Classifier: Intended Audience :: System Administrators
|
|
6
|
+
Classifier: Intended Audience :: Education
|
|
7
|
+
Classifier: Topic :: Software Development
|
|
8
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Summary: Binary protocol specializes exclusively in the ultra-fast serialization and deserialization of Python's built-in types
|
|
18
|
+
Keywords: binary,python,protocol,pd_proto,PeaceData,PDProto,pickle,serialization,proto,buffer
|
|
19
|
+
Author-email: kotolex <farofwell@gmail.com>
|
|
20
|
+
License-Expression: AGPL-3.0-only OR LicenseRef-Proprietary
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
23
|
+
Project-URL: Homepage, https://github.com/kotolex/pd_proto
|
|
24
|
+
|
|
25
|
+
# pd_proto (Peace Data Protocol)
|
|
26
|
+
|
|
27
|
+
> All detailed technical specifications, internal byte structures, layout constraints, and type tags can be explored in the comprehensive [Protocol Specification](SPECIFICATION.md).
|
|
28
|
+
|
|
29
|
+
## Introduction
|
|
30
|
+
|
|
31
|
+
Python has firmly established itself as the most popular and widely adopted programming language in the world. At the heart of virtually every Python application - ranging from microservices and web backends to data pipelines and machine learning infrastructure - lies the heavy utilization of standard built-in data types.
|
|
32
|
+
|
|
33
|
+
Because standard applications spend the vast majority of their CPU cycles manipulating and transmitting these exact primitives, **`pd_proto` specializes exclusively in the ultra-fast serialization and deserialization of Python's native built-in types**. By focusing on data structures rather than complex object graphs, class inheritance, or custom behavior, `pd_proto` bypasses the systemic overhead found in traditional serialization frameworks.
|
|
34
|
+
|
|
35
|
+
## Core Advantages
|
|
36
|
+
|
|
37
|
+
* **Zero Dependencies:** Built entirely with native Python C-API bindings and a highly optimized Rust core, requiring no third-party libraries or external runtimes.
|
|
38
|
+
* **Platform & Runtime Independent:** Fully decoupled from the underlying Operating System and specific Python version updates, ensuring absolute portability across Linux, macOS, and Windows.
|
|
39
|
+
* **Minimal Binary Footprint:** Generates compiled payloads that are significantly smaller than equivalent byte streams produced by native `pickle` or `json`.
|
|
40
|
+
* **Blazing Fast Performance:** Drastically outperforms native CPython serializers by stripping away dynamic object reflection and memory allocation overhead.
|
|
41
|
+
|
|
42
|
+
## Key Architectural Enhancements
|
|
43
|
+
|
|
44
|
+
Knowing the practical realities of data transmission, `pd_proto` introduces several architectural mechanics to maximize efficiency:
|
|
45
|
+
|
|
46
|
+
* **Varint Length Encoding:** Length descriptors for collections, strings, and integers utilize variable-length integers (LEB128). Short data segments consume a single byte for length instead of being penalized by fixed 4-byte or 8-byte headers.
|
|
47
|
+
* **Optimized Floating-Point Structures:** Primitives with up to 6 decimal places (such as `12.22` or `3.14`) undergo an automated scaling routine that condenses standard 8-byte IEEE 754 floats into tightly packed Varints.
|
|
48
|
+
* **Intelligent Inline Tags:** Highly recurrent constants (`0`, `1`–`13`, `100`, `1000`) and standard short collection shapes (e.g., a tuple containing exactly 2 or 3 elements) utilize dedicated optimizing tags. This entirely removes the need to write separate size or value descriptors into the stream.
|
|
49
|
+
* **Localized String & Big Integers & Float Caching:** The processing pipeline uses isolated, bounded in-memory caches during execution. By avoiding repeated memory allocation in the Python heap for highly recurrent strings or numeric primitives, the parser maintains an incredibly low execution profile that easily fits into the CPU's L1 cache.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
Install the compiled library directly from PyPI using `pip`:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install pd_proto
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Supported Types
|
|
60
|
+
|
|
61
|
+
The protocol strictly and natively processes the following built-in types:
|
|
62
|
+
`None` | `bool` | `int` | `float` | `str` | `bytes` | `list` | `tuple` | `dict` | `set` | `datetime`
|
|
63
|
+
|
|
64
|
+
*Note: User-defined subclasses or structures containing application-specific logic must be sanitized and converted into a standard native schema (such as a dictionary or tuple) prior to serialization.*
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
Just like with pickle and json, use dumps to serialize data and loads to deserialize it.
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from pd_proto import dumps, loads
|
|
72
|
+
|
|
73
|
+
data = {"text": "some text", "is_valid": True, "unique_tags": {"apple", "banana", "cherry"}}
|
|
74
|
+
bts = dumps(data)
|
|
75
|
+
print(bts) # b'\x01\x11\x03,text1some text0is_valid\x013unique_tags\x10\x03.banana-apple.cherry'
|
|
76
|
+
parsed = loads(bts)
|
|
77
|
+
print(parsed) # {'text': 'some text', 'is_valid': True, 'unique_tags': {'banana', 'apple', 'cherry'}}
|
|
78
|
+
assert data == parsed # The protocol guarantees equality after deserialization
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
You can use any supported (built-in) types and collections composed of supported types. If an unsupported type is encountered in the data, you will receive a clear error message about it.
|
|
82
|
+
|
|
83
|
+
### Parameters
|
|
84
|
+
|
|
85
|
+
You can configure certain serialization parameters to boost speed at the cost of the resulting byte array size. Since optimal defaults are already selected, tweaking these settings is generally not recommended.
|
|
86
|
+
|
|
87
|
+
**max_depth** - Specifies the maximum allowed nesting depth for collections, throwing an exception if exceeded. Defaults to 1000. Setting it to a negative value or 0 disables the depth check, which may lead to stack overflow and application crashes.
|
|
88
|
+
|
|
89
|
+
**float_limit** - Specifies the threshold for float optimization. For details on how this optimization works, refer to the protocol specification. Defaults to 268_435_455.0. If set to a negative value or 0, no attempts will be made to optimize float sizes. This may boost performance but expands the result size since every float takes up 8 bytes.
|
|
90
|
+
|
|
91
|
+
**string_length_limit** - Specifies the string size threshold for compression. Strings larger than this value (in bytes) will be compressed. Defaults to 100 bytes. If set to a negative value or 0, no strings will be compressed - for instance, if you know the data is already incompressible.
|
|
92
|
+
|
|
93
|
+
### Errors
|
|
94
|
+
|
|
95
|
+
Every error has a clear, self-explanatory name and includes a message describing the issue. If you are unsure which specific exception might be raised, you can catch the base exception for all protocol errors(PDProtoError).
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from pd_proto import dumps, PDProtoError
|
|
99
|
+
|
|
100
|
+
data = frozenset([1, 2])
|
|
101
|
+
try:
|
|
102
|
+
bts = dumps(data)
|
|
103
|
+
except PDProtoError:
|
|
104
|
+
print("Cant use it") # frozenset is not supported!
|
|
105
|
+
```
|
|
106
|
+
**Note on frozenset:** Despite being a built-in type, `frozenset` is seldom used and is identical to a standard `set` from a data perspective (ignoring behavior). If you need to serialize it, just use a regular `set`.
|
|
107
|
+
|
|
108
|
+
## Comparison with JSON
|
|
109
|
+
|
|
110
|
+
The primary benefit of JSON over `pd_proto` is human-readability. Otherwise, JSON produces larger payloads and performs slower.
|
|
111
|
+
|
|
112
|
+
For obvious architectural reasons, the binary payloads generated by `pd_proto` are significantly more compact - often reducing data size by up to 50% compared to standard JSON text strings. `pd_proto` delivers substantially faster execution speeds while simultaneously maintaining a much smaller byte footprint.
|
|
113
|
+
|
|
114
|
+
Furthermore, unlike JSON, `pd_proto` provides native, out-of-the-box support for complex types and states such as `datetime`, `set`, `tuple`, `bytes` as well as IEEE 754 special float values (`NaN`, `Inf`, and `-Inf`).
|
|
115
|
+
|
|
116
|
+
A notorious limitation of JSON is its inability to serialize bytes and dates, forcing developers to convert it into text strings. This introduces the systemic overhead of string parsing on the receiving end, which requires strict prior coordination of the exact date format or bytes encoding. `pd_proto` completely eliminates this friction, packing and restoring directly into standard Python `datetime` or `bytes` objects.
|
|
117
|
+
|
|
118
|
+
* **Important Notice on Naive Datetimes:** Please note that naive `datetime` objects (those without an explicit timezone) are serialized as raw timestamps. If a naive datetime is packed on a machine in one geographic timezone and unpacked on a machine running in a different timezone, its absolute value will shift accordingly. This fully mirrors native CPython runtime behavior and must be accounted for during cross-region data transfers.
|
|
119
|
+
|
|
120
|
+
## Comparison with Pickle
|
|
121
|
+
|
|
122
|
+
While `pickle` is highly optimized and executes rapidly (particularly within Linux environments), `pd_proto` delivers matching or superior processing speeds depending on the specific volume and composition of the dataset. Besides, `pd_proto` consistently yields a more compact serialized byte footprint.
|
|
123
|
+
|
|
124
|
+
A distinct advantage of `pickle` is its inherent capacity to serialize user-defined class instances and custom subclasses derived from built-in types - a capability explicitly omitted from `pd_proto`.
|
|
125
|
+
Instead, `pd_proto` maintains a strict, uncompromised focus on data structures, ensuring maximum throughput and minimal storage footprint.
|
|
126
|
+
|
|
127
|
+
Furthermore, `pd_proto` is entirely decoupled from specific Python runtime versions and is uniformly optimized across all operating systems, whereas `pickle` exhibits a pronounced performance bias toward Linux environments.
|
|
128
|
+
|