Skip to content

Commit

Permalink
13 support gmp for variable size numbers (#22)
Browse files Browse the repository at this point in the history
* feat(buildext.py): build GMP extension

* perf(pyproject.toml): build command

* perf(CMakeLists.txt): link GMP library

* perf(pyproject.toml): fastest group with gmpy2

* perf(noxfile.py): tests for fastest

* feat(fastest): common.py)

* feat(fastest): base26.py

* feat(fastest): base52.py

* feat(fastest): __init__.py

* perf(__init__.py): native or fastest

* perf(common.py): mpz drop-in conversion

co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>

* fix: C++ implementation

* fix: pre-commit linting

* perf: README

* fix: C++ formatting config

* fix: pre-commit config

* feat: uv package

* feat: polishing

* fix: README

---------

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
  • Loading branch information
DiTo97 and skirpichev authored Dec 8, 2024
1 parent 437caeb commit d5efc85
Show file tree
Hide file tree
Showing 35 changed files with 1,505 additions and 420 deletions.
9 changes: 0 additions & 9 deletions .clang-format

This file was deleted.

2 changes: 1 addition & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exemptLabels:
- security
staleLabel: won't fix
markComment: >
The issue has been automatically marked as stale since it has not had recent activity;
The issue has been automatically marked as stale since it has not had recent activity;
will be closed if no further activity occurs. TY for the contribution.
closeComment: false
exemptProjects: true
Expand Down
35 changes: 14 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"
autoupdate_commit_msg: "chore: pre-commit"
autofix_commit_msg: "style: pre-commit"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.8"
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
exclude: ^(docs)
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
files: ^(src|tests)
- id: ruff-format
exclude: ^(docs)
files: ^(src|tests)

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.0
hooks:
- id: cmake-format
additional_dependencies: [pyyaml]
types: [file]
files: (\.cmake|CMakeLists.txt)(.in)?$

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v13.0.0
hooks:
- id: clang-format
- id: uv-lock
- id: uv-export
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
17 changes: 0 additions & 17 deletions CMakeLists.txt

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ base26 ([A-Z]) and base52 ([A-Za-z]) encodings

transform any string to alphabetic-only with base26 ([A-Z]) and base52 ([A-Za-z]) lossless encodings; useful for transmitting textual data over restrictive channels or for training AI models and tokenizers on simpler vocabularies.

**alphacodings** is a fast and lightweight C++ library; bindings are available via pybind11.
**alphacodings** is a fast and lightweight library using [GMP arithmetic](https://gmplib.org).

## ⚙️ installation

Expand Down Expand Up @@ -54,15 +54,15 @@ if __name__ == "__main__":

## 🧠 motivation

The library is inspired by [R. Heaton](https://github.com/robert)'s base26 implementation in the [pyskyWiFi](https://github.com/robert/PySkyWiFi) repository and his story on how to manipulate data transmission in restrictive network channels via alphabetic-only encodings and tokenization.
The library is inspired by [R. Heaton](https://github.com/robert)'s base26 implementation and his story on manipulating data transmission in restrictive network channels on transatlantic flights using alphabetic-only encodings and tokenization.

have a look at the original repository and [story blog post](https://robertheaton.com/pyskywifi) and show him some love!
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!

## 📊 benchmarking

TBC <!-- HTML string of almost 2.5M characters -->

## 🤝 contributing
## 🤝 contributing

contributions to **alphacodings** are welcome!

Expand Down
27 changes: 0 additions & 27 deletions alphacodings/__init__.py

This file was deleted.

5 changes: 0 additions & 5 deletions alphacodings/_native/__init__.py

This file was deleted.

9 changes: 0 additions & 9 deletions alphacodings/_native/common.py

This file was deleted.

6 changes: 3 additions & 3 deletions benchmark/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
def main():
M = [] # functions
N = [] # arguments

efficiency = {closure.__name__: {"elapsed": [], "space": []} for closure in M}

for arg in tqdm(N, desc="alphacodings"):
for closure in M:
elapsed, space = measure(closure, arg)

efficiency[closure.__name__]["elapsed"].append(elapsed)
efficiency[closure.__name__]["space"].append(space)

plot_measure_efficiency(N, efficiency)


Expand Down
4 changes: 2 additions & 2 deletions benchmark/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def plot_measure_efficiency(N: list[int], efficiency: dict[str, Tracker]):
plt.figure(figsize=(12, 6))

plt.subplot(1, 2, 1)

for config in efficiency:
plt.plot(N, efficiency[config]["elapsed"], label=config)

Expand All @@ -26,7 +26,7 @@ def plot_measure_efficiency(N: list[int], efficiency: dict[str, Tracker]):
plt.title("elapsed efficiency")

plt.subplot(1, 2, 2)

for config in efficiency:
plt.plot(N, efficiency[config]["space"], label=config)

Expand Down
2 changes: 1 addition & 1 deletion benchmark/profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def measure(closure: typing.Callable[..., Any], *args: Any, **kwargs: Any) -> tu
"""measures the elapsed and space efficiency of a closure"""
start = time.perf_counter()
space = memory_usage((closure, args, kwargs), interval=0.1, max_usage=True)

elapsed = time.perf_counter() - start

return elapsed, space
13 changes: 0 additions & 13 deletions include/base26.hpp

This file was deleted.

13 changes: 0 additions & 13 deletions include/base52.hpp

This file was deleted.

14 changes: 0 additions & 14 deletions include/common.hpp

This file was deleted.

40 changes: 0 additions & 40 deletions noxfile.py

This file was deleted.

Loading

0 comments on commit d5efc85

Please sign in to comment.