Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions kaitai/python/kaitai_sbp/parse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import binascii
import sys
import base64
from io import SEEK_SET, SEEK_CUR, SEEK_END


SBP_HEADER_LEN = 6
Expand All @@ -28,8 +29,14 @@ def read(self, size=-1):
self.pos += size
return buf

def seek(self, pos):
self.pos = pos
def seek(self, offset, whence=SEEK_SET):
if whence == SEEK_SET:
self.pos = offset
elif whence == SEEK_CUR:
self.pos += offset
elif whence == SEEK_END:
self.pos = len(self.buf) + offset
return self.pos

def tell(self):
return self.pos
Expand Down
2 changes: 1 addition & 1 deletion kaitai/python/kaitai_sbp/tests/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ envlist = py
[testenv]
deps =
pytest
kaitaistruct==0.10.0
kaitaistruct
construct
python-rapidjson
changedir = ../../../..
Expand Down
3 changes: 1 addition & 2 deletions python/Dockerfile.benchmark
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ ADD . /work

RUN pip3 install -r /work/setup_requirements.txt
RUN pip3 install -r /work/requirements.txt
# keep in sync with above
RUN pip3 install kaitaistruct==0.10.0
RUN pip3 install kaitaistruct

RUN pip3 install wheel setuptools

Expand Down
8 changes: 4 additions & 4 deletions test_data/benchmark_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@

# How much faster Rust should be than other implementations
RATIOS_SBP2JSON = {
"haskell": 3.2,
"python": 23.38,
"haskell": 4.02,
"python": 18.7,
"kaitai_python": 5.00,
"kaitai_perl": 20,
"kaitai_perl": 24.05,
}

RATIOS_JSON2SBP = {
"haskell": 2.05,
}

RATIOS_JSON2JSON = {
"haskell": 2.40,
"haskell": 3.12,
}

FAILED = [False]
Expand Down