Implements Base1 (from qntm) in a python library
Project description
base1 (python implementation)
This is a python implementation of Base1 encoding, as detailed in https://github.com/qntm/base1. It follows that API. I implemented this largely on 2025-12-29, for fun.
Fun fact: this project has to be called "base-one" on pypi because "base1" is considered too similar to an existing project, "basel". https://stackoverflow.com/a/71490005
It is a python library, but you can also use it as a simple command-line utility as a bonus. Given a string input, the first argument to the command, it gives you the base1n of that data. (Internally, the program takes whatever python gives it as the string that "is" argv[1] and then calls .encode() directly on that to get a bytes. If you're having problems with complicated utf-8/other-encoding characters, that might be the culprit.)
Qntm's base1 works with javascript concepts, which have analogues in python. So, we use bytes instead of UInt8Array or whatever, and int instead of BigInt. The names of functions uses snakecase instead of camelcase.
The algorithm to encode and decode base1, especially in closed form, is not entirely trivial if you just read qntm's readme. You can derive, with some analytical work. It's all there, but you have to think about it a little. (What does it mean, mathematically to, eg, "sort all possible buffers by length and then lexicographically"? that seems like it would take a lot of time for the CPU to execute). I purposefully did not read any of his code, so that I could use my own license instead of his. This software is public domain btw. Also, my test examples are just from his readme, which I'm treating as a standard (and also those cases as non-copyrightable due to the concept-expression merger for math (don't worry about that)).
I lost interest in this project after completing it but before testing it very well. I mean, I guess I do test it pretty well, because those test cases are how I figured out what the heck I was doing, but I don't know about code coverage, test framework, CI, etc etc.
Since the important part of Base1 encoding is the length of the base1 string, various (but not all) parts of this program refer to that concept as a "base1n" (it's just an int holding the value of the length instead of the string that is that long). That's... you know, kind of the joke of this whole project, when you get right down to it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file base_one-1.0.1.tar.gz.
File metadata
- Download URL: base_one-1.0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33cced0f50b8835ab9207609e11fec6ff319810b43dfbbfebc6939210fd03e0d
|
|
| MD5 |
6f1a0d4c3e2e7add530a58012056fbc3
|
|
| BLAKE2b-256 |
2172ec2d05d14a4736e29e6d4c7741a54cd3dd0650c516714668ff6ebcffc7ca
|
File details
Details for the file base_one-1.0.1-py3-none-any.whl.
File metadata
- Download URL: base_one-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
085d8f2c30fbcb5816974ba2e975c59e06093d7ee3d6239022c496cb246b561c
|
|
| MD5 |
5e00ae8306242a654242112160db04d9
|
|
| BLAKE2b-256 |
04fa60972b0dafbd16efe4a0fd754b7c3ca978944f0d829fd18e419b1720b4ca
|