This repository was archived by the owner on Nov 22, 2026. It is now read-only.
Repository navigation
mojo-pyformat v0.2.0
mojo-pyformat v0.2.0
Released: 2026-11-04 · Tag: v0.2.0 · Previous: v0.1.2
What it does
Python's format() for numbers in Mojo, with the same digits: {:.Nf}, thousands separators, g, e, and %, rounded on the double's exact binary value as CPython does.
Highlights
py_repr(x): Pythonrepr(float)digit for digit. Mojo 1.2's own float printing is not round-trip safe (it prints two different doubles as3.000000005061751e+16and writese+015); this is the fix when text must equal Python.
Changes
Added
py_repr, with 653reprrows in the oracle grid; whole numbers below 1e16 take an exact fast path.
Verified
| Check | Result |
|---|---|
scripts/ci.sh (15,511 lines vs Python 3.14 format and repr, every power of two included, plus 43,660 wide lines with 804 repr on random bits and subnormals) on Mojo 1.2.0; scripts/check.sh on 1.3.0.dev2026110305 |
PASS |
Known limits
py_reprtries up to 17 precisions withatoffor non-integral values, about 1 µs each; fine for output text, not for hot loops.
Upgrade / run
from pyformat import py_repr
Commits
- All commits from
v0.1.2to tagv0.2.0:git log v0.1.2..v0.2.0.