Skip to content

Commit bacd655

Browse files
committed
Bump to v0.1.3 with leb128
1 parent 3739ac3 commit bacd655

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "numcodecs-tokenize"
7-
version = "0.1.2"
7+
version = "0.1.3"
88
description = "Tokenization codec for the `numcodecs` buffer compression API"
99
readme = "README.md"
1010
license = "MPL-2.0"
1111
requires-python = ">=3.10"
1212
dependencies = [
13+
"leb128~=1.0.8",
1314
"numcodecs>=0.13.0,<0.17",
1415
"numpy~=2.0",
15-
"varint~=1.0.2",
1616
]
1717

1818
[dependency-groups]
@@ -35,5 +35,5 @@ addopts = ["--import-mode=importlib"]
3535
xfail_strict = true
3636

3737
[[tool.mypy.overrides]]
38-
module = ["numcodecs.*", "varint.*"]
38+
module = ["leb128.*", "numcodecs.*"]
3939
follow_untyped_imports = true

src/numcodecs_tokenize/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
from io import BytesIO
88

9+
import leb128
910
import numcodecs.compat
1011
import numcodecs.registry
1112
import numpy as np
12-
import varint
1313
from numcodecs.abc import Codec
1414

1515
from .typing import S, T, U
@@ -60,14 +60,14 @@ def encode(
6060
# message: dtype shape [padding] table indices
6161
message = []
6262

63-
message.append(varint.encode(len(dtype.str)))
63+
message.append(leb128.u.encode(len(dtype.str)))
6464
message.append(dtype.str.encode("ascii"))
6565

66-
message.append(varint.encode(len(shape)))
66+
message.append(leb128.u.encode(len(shape)))
6767
for s in shape:
68-
message.append(varint.encode(s))
68+
message.append(leb128.u.encode(s))
6969

70-
message.append(varint.encode(unique.size))
70+
message.append(leb128.u.encode(unique.size))
7171

7272
# select the smallest output data type that can encode the indices
7373
utype: np.dtype[np.unsignedinteger]
@@ -132,13 +132,13 @@ def decode(
132132
b = numcodecs.compat.ensure_bytes(buf)
133133
b_io = BytesIO(b)
134134

135-
dtype = np.dtype(b_io.read(varint.decode_stream(b_io)).decode("ascii"))
135+
dtype = np.dtype(b_io.read(leb128.u.decode_reader(b_io)).decode("ascii"))
136136

137137
shape = tuple(
138-
varint.decode_stream(b_io) for _ in range(varint.decode_stream(b_io))
138+
leb128.u.decode_reader(b_io) for _ in range(leb128.u.decode_reader(b_io))
139139
)
140140

141-
table_len = varint.decode_stream(b_io)
141+
table_len = leb128.u.decode_reader(b_io)
142142

143143
# select the smallest output data type that can encode the indices
144144
utype: np.dtype[np.unsignedinteger]

0 commit comments

Comments
 (0)