Decimo v0.9.0 — now with a CLI calculator and Python bindings

Version Mojo pixi

Hi Mojicians,

Decimo (previously known as DeciMojo) just hit v0.9.0 (compatible with Mojo v0.26.2) and is available right away via:

pixi add decimo

This time around, I wanted to experiment with a couple of features and see how far Mojo can go as a general-purpose language. Let me walk you through what’s new in Decimo.

CLI Arbitrary-Precision Calculator

This is probably the most fun part. Since ArgMojo is now fully functional (supports subcommands, autocompletion, interactive prompting, compile-time validation — basically everything you’d expect from a CLI framework), I thought: why not dogfood it and build an actual app?

So decimo is now also a command-line calculator. You type an expression, it evaluates it with arbitrary precision. It’s got a proper tokenizer, a shunting-yard parser, and an RPN evaluator under the hood — all in pure Mojo, compiled to a single native binary with zero runtime dependencies.

% decimo 1/3+1/7  
0.47619047619047619047619047619047619047619047619048

% decimo "sqrt(2)" -p 50
1.4142135623730950488016887242096980785696718753769

% decimo "pi * sqrt(11.1^15)" --engineering -p 100
217.3062481188781475831859094865556029360927703474185717693262086138432884379636518929905574763204566E+6

You can also configure output formatting — scientific notation (-s), engineering notation (-e), digit delimiters (-d), rounding modes (-r), precision (-p), and more.

Here’s a quick demo of calculating an expression:

Calculation demo

And here’s what decimo -h looks like (automatically generated by ArgMojo):

Help output

Honestly, it makes me really happy to see that Mojo can be used as an application programming language — building real tools with proper argument parsing, coloured error messages, the whole thing. It just works.


Python Bindings

Also new in this release: Decimo now has Python bindings via Mojo’s PythonModuleBuilder. The BigDecimal type is exposed as a native CPython extension module (_decimo.so) with a Pythonic Decimal wrapper.

It’s available on PyPI: pypi.org/project/decimo

from decimo import Decimal

a = Decimal("1.234567890123456789012345678901234567890")
b = Decimal("9.876543210987654321098765432109876543210")
print(a + b)
print(a * b)

Still at an early stage — no pre-built wheels yet — but it already proves that Mojo’s interoperability with Python is very strong. Calling Mojo from Python and vice versa is becoming genuinely practical.


Other Highlights

  • A bunch of new BigDecimal methods aligned with Python’s decimal.Decimal and IEEE 754: as_tuple(), adjusted(), fma(), scaleb(), same_quantum(), copy_abs(), copy_sign(), __float__(), engineering notation, digit-group delimiters, and the ROUND_HALF_DOWN rounding mode (7 modes total now).
  • TOMLMojo is merged into Decimo as the sub-package decimo.toml.
  • Codebase updated to Mojo v0.26.2 syntax (byte= slicing, out parameter convention, etc.).

Full changelog: github.com/forfudan/decimo/releases


I’m very optimistic about the future of Mojo. Each release feels like a step closer to a language that’s both fast and pleasant to build real software with.

As always, feedback and issues are welcome on the repo. Happy hacking! :fire:

9 Likes

The calculator is a pretty cool “pythonic” addition :slight_smile:

Yes, finally we are all Pythonistas :smiley: