Skip to main content

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, and int instead of BigInt. The names of functions use 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 it, with some analytical work. It's all there, but you have to think about it a little. (What does it mean, mathematically or in terms of computer operations, 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. (And also to treat it as a fun riddle for a moment.) This software is public domain btw. Also, most of my test examples are just from his readme, which I'm treating as a standard (and also I'm treating 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.

Metadata

Release files for base-one 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for base-one 1.0.2
File Size Uploaded Provenance
base_one-1.0.2.tar.gz 3.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for base-one 1.0.2
File Interpreter ABI Platform
base_one-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 6.4 kB

Release files / base_one-1.0.2.tar.gz

Download URL base_one-1.0.2.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cdf252f56d7445fe9cb0045daed58c3760e3d1fee5b31b4c4c213322d2f6d69b
BLAKE2b-256 checksum
How to use checksums
683d174f9b3517806aab181533bf12172a8b62efbd6c46f02e45bc12b69d8e2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / base_one-1.0.2-py3-none-any.whl

Download URL base_one-1.0.2-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f1179863d20a40fa10952ee544686881e1460e456f4dd446242d01fe36ebb87
BLAKE2b-256 checksum
How to use checksums
0a87c1fb6eb87543bf9b1ee7df4ba90e4c7805593e8c37c1f56f9ad3977c5724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for base-one 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page