Skip to content

Commit a8db27e

Browse files
authored
15 automatic chunking (#24)
* perf: benchmark timeout running experiments * perf: benchmark caption * fix: caption wording * fix: caption typo * fix: caption mention of average trials * fix: strict in caption * fix: center alignment * fix: distribution
1 parent 9f93013 commit a8db27e

File tree

16 files changed

+129
-1029
lines changed

16 files changed

+129
-1029
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ repos:
1818
hooks:
1919
- id: ruff
2020
args: [--fix, --exit-non-zero-on-fix]
21-
files: ^(src|tests)
2221
- id: ruff-format
2322
exclude: ^(docs)
24-
files: ^(src|tests)
2523

2624
- repo: https://github.com/astral-sh/uv-pre-commit
2725
rev: 0.5.0

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ string = """\
4242
if __name__ == "__main__":
4343
encoding_base26 = base26_encode(string)
4444
print(encoding_base26)
45-
# >>> YBPNLKVNQWZQCMDHMLNDTVQCCRKQLNCFGMQPNGQCIXHUUPHFUNKUFEPDLKIGARFOKTDEZKQHXGCPYHDZKKVIUDNFOAYYAUOQFBJFFGSTKAXNWGDPVUJNBARPNXBASHZBXIBSSEFTAIQRPEADSOVVNXUMQXVDWTAIVCIVWQZAHAGYAVZYKGMETJOOUQNOEXMSOOGSKVMFBYZIBZDAITICYVXMJTTCCHPMSCABLYUMFDUNLVSLNKHSBPKCGASXJSFYDHZFAOEQTUACEBIFKQGYC
45+
# >>> ["YBPNLKVNQWZQCMDHMLNDTVQCCRKQLNCFGMQPNGQCIXHUUPHFUNKUFEPDLKIGARFOKTDEZKQHXGCPYHDZKKVIUDNFOAYYAUOQFBJFFGSTKAXNWGDPVUJNBARPNXBASHZBXIBSSEFTAIQRPEADSOVVNXUMQXVDWTAIVCIVWQZAHAGYAVZYKGMETJOOUQNOEXMSOOGSKVMFBYZIBZDAITICYVXMJTTCCHPMSCABLYUMFDUNLVSLNKHSBPKCGASXJSFYDHZFAOEQTUACEBIFKQGYC"]
4646

4747
encoding_base52 = base52_encode(string)
4848
print(encoding_base52)
49-
# >>> EgcgYRPxckylMQWRLDADNZxPJiJcHaVwYHLnicahBgaotGGANZuvsvcpSSOJFLXvKPjRlNQCJqqdviiIdtnwJyDOnWojsrpkWSTZFHbMIREvREjpsODtSxoLlLjQZOoehsGFzawGQecyuomgpZQNyFnZQLWPiDhzClwxBFCCwdqduGJoshrwFdwHWMtJpSTmjxzaYmNvzOIOwLkJvyQHCaFtrODPhbhBpPBmC
49+
# >>> ["EgcgYRPxckylMQWRLDADNZxPJiJcHaVwYHLnicahBgaotGGANZuvsvcpSSOJFLXvKPjRlNQCJqqdviiIdtnwJyDOnWojsrpkWSTZFHbMIREvREjpsODtSxoLlLjQZOoehsGFzawGQecyuomgpZQNyFnZQLWPiDhzClwxBFCCwdqduGJoshrwFdwHWMtJpSTmjxzaYmNvzOIOwLkJvyQHCaFtrODPhbhBpPBmC"]
5050

5151
assert base26_decode(encoding_base26) == string
5252
assert base52_decode(encoding_base52) == string
@@ -56,11 +56,17 @@ if __name__ == "__main__":
5656

5757
The library is inspired by [R. Heaton](https://github.com/robert)'s base26 implementation and his story of manipulating data transmission in restrictive network channels on long-distance flights using alphabetic-only encodings and tokenization.
5858

59-
have a look at the original [repository](https://github.com/robert/pyskywifi) and [blog post](https://robertheaton.com/pyskywifi) and show him some love!
59+
have a look at the original [repository](https://github.com/robert/pyskywifi) and story [blog post](https://robertheaton.com/pyskywifi) and show him some love.
6060

6161
## 📊 benchmarking
6262

63-
TBC <!-- HTML string of almost 2.5M characters -->
63+
our implementation is orders of magnitude more efficient on 100k+ strings:
64+
65+
<div align="center">
66+
<img src="resources/benchmark.png" alt="benchmarking">
67+
68+
*Figure 1: runtime and memory usage performance against Heaton's original implementation with and without automatic chunking and SIMD on variable-length strings with a strict 60-second timeout; average over 5 trials.*
69+
</div>
6470

6571
## 🤝 contributing
6672

benchmark/__main__.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

benchmark/plotting.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

benchmark/profiling.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
55

66
[project]
77
name = "alphacodings"
8-
version = "0.1.0"
8+
version = "0.2.0"
99
description = "base26 ([A-Z]) and base52 ([A-Za-z]) encodings"
1010
readme = "README.md"
1111
authors = [{name = "Federico Minutoli", email = "fede97.minutoli@gmail.com"}]
@@ -16,16 +16,15 @@ dependencies = ["gmpy2>1"]
1616

1717

1818
[dependency-groups]
19-
contrib = ["matplotlib>3", "memory-profiler>0", "pre-commit>4", "tqdm>4"]
20-
testing = ["pytest>8"]
19+
contrib = ["pre-commit>4", "pytest>8"]
2120

2221

2322
[tool.uv]
24-
default-groups = ["contrib", "testing"]
23+
default-groups = ["contrib"]
2524

2625

2726
[tool.ruff]
28-
src = ["src"]
27+
src = ["src", "tests"]
2928
exclude = [
3029
".git-rewrite",
3130
".git",
@@ -76,8 +75,10 @@ extend-select = [
7675
"YTT",
7776
]
7877
ignore = [
78+
"E741",
7979
"PLR09",
8080
"PLR2004", # magic comparison
81+
"RET504",
8182
]
8283

8384
[tool.ruff.lint.isort]

0 commit comments

Comments
 (0)