Skip to main content

calc_rs

A strongly typed, spreadsheet-style expression engine — currency, tonnage, percentages, dates, durations, and tables are distinct first-class types, not just decorated numbers. A Rust rewrite of Attica-oss/calc, usable as a CLI, a Rust library, or a Python extension module.

Install

CLI (from source, requires Rust):

cargo install --path . --bin calc_rs

Python:

pip install calc-rs-lang

CLI usage

calc_rs '$5.00 * 3'            # $15.00  (currency)
calc_rs                        # start the REPL
calc_table new "item:text, price:currency, qty:int" table.json

Python usage

import calc_rs

calc_rs.evaluate("$5.00 * 3")          # Currency($15.00)
calc_rs.evaluate("1 + 2 * 3")          # 7

calc = calc_rs.Calculator()
calc.set("price", calc_rs.Currency("12.50"))
calc.eval("price * 3")                 # Currency($37.50)

Currency, duration, and complex-number results come back as dedicated classes (.amount, .months/.days/.seconds, .real/.imag); numbers, text, booleans, and dates/times come back as native Python types.

Notebook

A marimo notebook backed by this engine lives in notebook/, replicating the expression-editor and table-builder workflow of the original Python project's notebook:

pip install -e '.[notebook]'
maturin develop --release
marimo edit notebook/calc_notebook.py

Development

cargo test                     # engine tests
maturin develop --release      # build + install the Python extension

License

MIT — see LICENSE.

Release files for calc-rs-lang 0.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for calc-rs-lang 0.1.0
File Interpreter ABI Platform
calc_rs_lang-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details

Release files / calc_rs_lang-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL calc_rs_lang-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f2cfae8194df37b626efbfc98ff63c9a09975eafd9a03ce37ac7a39ad9104a7a
BLAKE2b-256 checksum
How to use checksums
000a4476c40b7875809583c81519b46bcbe43d9c8055a5352affac62f68bf05b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.2.1

6 release files

0.2.0

6 release files

This release

0.1.0 This release

1 release file

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