dybuf 0.2.0__tar.gz → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dybuf
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Python bindings for the dybuf dynamic buffer library.
5
5
  Author-email: Yuchi <yuchi518@gmail.com>
6
6
  Maintainer-email: Yuchi <yuchi518@gmail.com>
@@ -44,7 +44,8 @@ Python bindings for the [`dybuf`](../c/dybuf.h) dynamic buffer library implement
44
44
  ## Key features
45
45
 
46
46
  - Thin, fast wrapper around the original `dybuf` implementation.
47
- - Supports reading and writing unsigned integers (8–64 bits), booleans, and raw byte payloads.
47
+ - Supports reading and writing unsigned integers (8–64 bits), booleans, raw byte payloads, and the library’s compact `var_u64`/`var_s64` varints.
48
+ - Exposes typdex markers so higher-level protocols can tag fields without hauling in a full protobuf-style schema.
48
49
  - Compatible with Windows, Linux, and macOS thanks to compiled extension modules.
49
50
  - Designed for publishing on PyPI with automated release workflows.
50
51
 
@@ -76,6 +77,27 @@ print(buf.next_bool()) # True
76
77
 
77
78
  `write()` and `read()` let you work directly with arbitrary byte payloads, while `position`, `limit`, and `capacity` expose the cursor-style API provided by the original library.
78
79
 
80
+ ## Variable-length integers
81
+
82
+ `DyBuf` supports zig-zag encoded signed integers and unsigned integers using the same compact varint scheme the C library exposes. These helpers keep the payload small for numbers that fit in a few bits.
83
+
84
+ ```python
85
+ from dybuf import DyBuf
86
+
87
+ buf = (
88
+ DyBuf(capacity=32)
89
+ .append_var_s64(-123)
90
+ .append_var_u64(300)
91
+ )
92
+
93
+ buf.flip()
94
+
95
+ print(buf.next_var_s64()) # -123
96
+ print(buf.next_var_u64()) # 300
97
+ ```
98
+
99
+ Use `append_var_s64` / `next_var_s64` when you need negative values; the encoding automatically performs zig-zag conversion under the hood. For values that are always non-negative, stick to `append_var_u64` / `next_var_u64` to avoid the extra zig-zag step. The legacy `append_var_int` / `next_var_int` and `append_var_uint` / `next_var_uint` aliases still work but emit `DeprecationWarning` so callers can migrate. The same encoding also powers `append_var_bytes` and `append_var_string`, which prefix their payload with a varint length field for round-tripping arbitrary byte sequences.
100
+
79
101
  ## Typdex markers
80
102
 
81
103
  `DyBuf` also exposes helpers for working with the library's **typdex** encodings—a compact representation of a logical type paired with an index. These markers are commonly used by higher-level protocols such as `dypkt` to describe field layouts or function identifiers.
@@ -128,7 +150,7 @@ open docs/_build/html/index.html # or use your preferred viewer
128
150
 
129
151
  ## Automated releases
130
152
 
131
- A GitHub Actions workflow under `.github/workflows/pypi-release.yml` drives [cibuildwheel](https://github.com/pypa/cibuildwheel) to produce Windows, Linux, and macOS artifacts and publish them to PyPI. Provide a `PYPI_API_TOKEN` secret in your repository and tag releases with a semantic version (e.g. `v0.2.0`) to trigger the pipeline.
153
+ A GitHub Actions workflow under `.github/workflows/pypi-release.yml` drives [cibuildwheel](https://github.com/pypa/cibuildwheel) to produce Windows, Linux, and macOS artifacts and publish them to PyPI. Provide a `PYPI_API_TOKEN` secret in your repository and tag releases with a semantic version (e.g. `v0.3.0`) to trigger the pipeline.
132
154
 
133
155
  ## Licensing
134
156
 
@@ -5,7 +5,8 @@ Python bindings for the [`dybuf`](../c/dybuf.h) dynamic buffer library implement
5
5
  ## Key features
6
6
 
7
7
  - Thin, fast wrapper around the original `dybuf` implementation.
8
- - Supports reading and writing unsigned integers (8–64 bits), booleans, and raw byte payloads.
8
+ - Supports reading and writing unsigned integers (8–64 bits), booleans, raw byte payloads, and the library’s compact `var_u64`/`var_s64` varints.
9
+ - Exposes typdex markers so higher-level protocols can tag fields without hauling in a full protobuf-style schema.
9
10
  - Compatible with Windows, Linux, and macOS thanks to compiled extension modules.
10
11
  - Designed for publishing on PyPI with automated release workflows.
11
12
 
@@ -37,6 +38,27 @@ print(buf.next_bool()) # True
37
38
 
38
39
  `write()` and `read()` let you work directly with arbitrary byte payloads, while `position`, `limit`, and `capacity` expose the cursor-style API provided by the original library.
39
40
 
41
+ ## Variable-length integers
42
+
43
+ `DyBuf` supports zig-zag encoded signed integers and unsigned integers using the same compact varint scheme the C library exposes. These helpers keep the payload small for numbers that fit in a few bits.
44
+
45
+ ```python
46
+ from dybuf import DyBuf
47
+
48
+ buf = (
49
+ DyBuf(capacity=32)
50
+ .append_var_s64(-123)
51
+ .append_var_u64(300)
52
+ )
53
+
54
+ buf.flip()
55
+
56
+ print(buf.next_var_s64()) # -123
57
+ print(buf.next_var_u64()) # 300
58
+ ```
59
+
60
+ Use `append_var_s64` / `next_var_s64` when you need negative values; the encoding automatically performs zig-zag conversion under the hood. For values that are always non-negative, stick to `append_var_u64` / `next_var_u64` to avoid the extra zig-zag step. The legacy `append_var_int` / `next_var_int` and `append_var_uint` / `next_var_uint` aliases still work but emit `DeprecationWarning` so callers can migrate. The same encoding also powers `append_var_bytes` and `append_var_string`, which prefix their payload with a varint length field for round-tripping arbitrary byte sequences.
61
+
40
62
  ## Typdex markers
41
63
 
42
64
  `DyBuf` also exposes helpers for working with the library's **typdex** encodings—a compact representation of a logical type paired with an index. These markers are commonly used by higher-level protocols such as `dypkt` to describe field layouts or function identifiers.
@@ -89,7 +111,7 @@ open docs/_build/html/index.html # or use your preferred viewer
89
111
 
90
112
  ## Automated releases
91
113
 
92
- A GitHub Actions workflow under `.github/workflows/pypi-release.yml` drives [cibuildwheel](https://github.com/pypa/cibuildwheel) to produce Windows, Linux, and macOS artifacts and publish them to PyPI. Provide a `PYPI_API_TOKEN` secret in your repository and tag releases with a semantic version (e.g. `v0.2.0`) to trigger the pipeline.
114
+ A GitHub Actions workflow under `.github/workflows/pypi-release.yml` drives [cibuildwheel](https://github.com/pypa/cibuildwheel) to produce Windows, Linux, and macOS artifacts and publish them to PyPI. Provide a `PYPI_API_TOKEN` secret in your repository and tag releases with a semantic version (e.g. `v0.3.0`) to trigger the pipeline.
93
115
 
94
116
  ## Licensing
95
117
 
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
8
8
 
9
9
  [project]
10
10
  name = "dybuf"
11
- version = "0.2.0"
11
+ version = "0.3.0"
12
12
  description = "Python bindings for the dybuf dynamic buffer library."
13
13
  readme = "README.md"
14
14
  authors = [{ name = "Yuchi", email = "yuchi518@gmail.com" }]
@@ -27,4 +27,5 @@ __all__ = [
27
27
  "TYPDEX_TYP_MAP",
28
28
  "TYPDEX_TYP_F",
29
29
  ]
30
- __version__ = "0.2.0"
30
+
31
+ __version__ = "0.3.0"