Skip to main content

calc — a scripting language for building things simply

CI PyPI calc-rs-lang PyPI calc-desktop Python 3.10+ Rust edition 2024 MIT license Open the notebook in molab

calc_rs

calc_rs is a strongly typed scripting language for calculations and structured data. The core is written in Rust, and is available as a CLI, Rust library, and Python extension module.

Key features

  • Strongly typed: Currency, percentages, dates, durations, tonnage, tables, and other domain values are distinct types rather than decorated numbers.

  • Calculations: Designed for real-world calculations with units and domain-specific values, while retaining a concise expression-oriented syntax.

  • Data & Tables: Tables are first-class values that can be created, transformed, queried, and persisted directly from the language — with grouped summaries, joins, window functions (lag, running_sum, rank), set operations and multi-key sorting.

  • Pipelines: Compose transformations with |>, making data workflows read from top to bottom instead of nesting operations.

  • Schema-aware: CSV, TSV, JSON Lines, Excel and OpenDocument files load with inferred or explicit schemas. Values are checked against their declared types rather than silently converted to text.

  • Maths: Exact decimals and fractions (fraction(1, 3) * 3 is 1/1), trigonometry and logarithms, vectors and matrices (linalg), ratios, proportional allocation, and random numbers.

  • Dates and calendars: Date ranges, month grids, business and working days, and public holidays from a configurable calendar.

  • From spreadsheets: Most Excel worksheet functions have a calc equivalent, and calc_rs doc --excel PMT finds it.

  • Scripting: Run individual expressions, .calc files, or multi-file projects with imports and modules.

  • Interactive: A REPL with syntax highlighting, completion, signatures, multi-line expressions, and session state.

  • Editor Support: Built-in Language Server support provides diagnostics, completion, and hover information.

  • Embeddable: Use the engine directly from Rust or Python.

  • Rust: Written in Rust with the performance-critical engine implemented natively and exposed through a library API.

Why calc_rs?

calc_rs is designed for programs where calculations and structured data are central to the problem.

Instead of treating everything as an untyped number or string, values carry their meaning and type:

let price = $12.50
let quantity = 3

price * quantity
// $37.50

The same language can work with structured data:

load("moves.csv")
  |> filter([status] != "Cancelled")
  |> inner_join(load("rates.csv"), "customer")
  |> extend("amount", [rate] * [tons])
  |> summarize(array("customer"),
       "tons", sum([tons]),
       "amount", sum([amount]),
       "moves", count())
  |> sort([amount], "desc")
╭──────────┬──────┬───────────┬───────╮
│ customer │ tons │    amount │ moves │
├──────────┼──────┼───────────┼───────┤
│ IOT      │ 34.5 │ $1,569.75 │     2 │
│ CCS      │ 30.0 │ $1,200.00 │     1 │
╰──────────┴──────┴───────────┴───────╯

Row-order functions read neighbouring rows, per group:

load("moves.csv")
  |> sort([date])
  |> extend(array("container"),
       "previous_date", lag([date]),
       "running_tons", running_sum([tons]))

Schemas can be declared explicitly when the shape of the data matters:

struct Shipment {
  date: date,
  port: text,
  box: container,
  amount: currency
}

load("jan.csv", Shipment)

This lets the language check data as it enters the program rather than discovering type problems later.

Numbers stay exact, and the maths library covers the rest:

(1 / 3) * 3                             // 0.9999999999999999999999999999
fraction(1, 3) * 3                      // 1/1

import "math" as math
math::allocate($100.00, array(1, 1, 1)) // [$33.34, $33.33, $33.33] — always sums to $100.00

import "linalg" as linalg
linalg::solve(matrix(array(2.0, 1.0), array(1.0, 3.0)), array(3.0, 5.0))  // [0.8, 1.4]

range(2026-01-31, 2026-06-01, 1mo)      // 31 Jan, 28 Feb, 31 Mar, 30 Apr, 31 May

Philosophy

The goal of calc_rs is to provide a scripting language that:

  • Keeps calculations concise without sacrificing strong typing.
  • Treats domain-specific values as real types.
  • Makes structured data and tables first-class language values.
  • Makes data transformations readable through pipelines.
  • Detects schema and type errors before they become silent data corruption.
  • Works interactively as well as in scripts and multi-file projects.
  • Can be embedded in both Rust and Python applications.
  • Provides useful editor tooling without requiring a separate runtime.

calc_rs is written in Rust, giving the engine control over its data representation and performance-critical execution while keeping the language small and embeddable.

Install

CLI

uv tool install calc-rust

Then:

calc_rs '$5.00 * 3'
# $15.00

Or run without installing:

uvx --from calc-rust calc_rs '$5.00 * 3'

Desktop app (Windows and macOS)

uv tool install calc-desktop
calc_desktop path/to/project

The app installs like the CLI — uv unpacks it into your user folder, so no installer runs. On Windows it needs the WebView2 runtime (included in Windows 11). On Linux, build it from desktop/ instead.

Python

pip install calc-rs-lang
import calc_rs

calc_rs.evaluate("$5.00 * 3")
# Currency($15.00)

Rust

[dependencies]
calc_rs = { git = "https://github.com/Attica-oss/calc_rs" }

Documentation

Development

cargo test
maturin develop --release

License

MIT — see LICENSE.

Metadata

Release files for calc-rs-lang 0.3.4

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

Source distribution (sdist)

Source distribution for calc-rs-lang 0.3.4
File Size Uploaded Provenance Actions
calc_rs_lang-0.3.4.tar.gz 1.7 MB With provenance Details for calc_rs_lang-0.3.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for calc-rs-lang 0.3.4
File Actions
calc_rs_lang-0.3.4-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for calc_rs_lang-0.3.4-cp310-abi3-win_amd64.whl
calc_rs_lang-0.3.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for calc_rs_lang-0.3.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
calc_rs_lang-0.3.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for calc_rs_lang-0.3.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
calc_rs_lang-0.3.4-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for calc_rs_lang-0.3.4-cp310-abi3-macosx_11_0_arm64.whl
calc_rs_lang-0.3.4-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for calc_rs_lang-0.3.4-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 15.5 MB

Release files / calc_rs_lang-0.3.4.tar.gz

Download URL calc_rs_lang-0.3.4.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
059ef898120d4102045df6f921e16d359a76b6feeedea21b6940d18ec8eafae4
BLAKE2b-256 checksum
How to use checksums
b98898a700f874a938804376b8d2f7e46b90ff35872329d6611e91b003c25727
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / calc_rs_lang-0.3.4-cp310-abi3-win_amd64.whl

Download URL calc_rs_lang-0.3.4-cp310-abi3-win_amd64.whl
Size 2.6 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
95c80e555e0f5fb0a3835232d95ade72ee6d7730c95a841f95ccc73f22aed027
BLAKE2b-256 checksum
How to use checksums
57aee955504c2b8708400e9bd7a1f8041d8264987a7d8bcef2b6c7d0ef853840
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

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

Download URL calc_rs_lang-0.3.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
fb67e45cc67ba19cb6da80bc2f836b1b3740ed6cd7d6f64dc4270be1909518d7
BLAKE2b-256 checksum
How to use checksums
59c9ebf22d6f5e04e07446cd58abf0dc469afa8ab4eb41222eda81e0c327d8da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / calc_rs_lang-0.3.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL calc_rs_lang-0.3.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.9 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
3d01d96088fd97dc2250a519c53b8f17147ce3508b930b17fd20d2d63aaa0dc8
BLAKE2b-256 checksum
How to use checksums
e64b969a24fc4a9a3369aeca8c3e2944e7c8e598457dd08b7486eea8bc85e1af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / calc_rs_lang-0.3.4-cp310-abi3-macosx_11_0_arm64.whl

Download URL calc_rs_lang-0.3.4-cp310-abi3-macosx_11_0_arm64.whl
Size 2.6 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9c8945ee557ab6ab5eefd2090444abba5272e342b7833c4e37910e78d23122cc
BLAKE2b-256 checksum
How to use checksums
6a696bc426a7390c77b38ae9762e33b98a1db4f3d183995cdea26b938e7d431c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / calc_rs_lang-0.3.4-cp310-abi3-macosx_10_12_x86_64.whl

Download URL calc_rs_lang-0.3.4-cp310-abi3-macosx_10_12_x86_64.whl
Size 2.7 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f202b17e3734d8817bdf36c4a7965b4437f7d293a175c2a40ecdc968d28c1104
BLAKE2b-256 checksum
How to use checksums
06f136623df69c0ad71a6f5ccb3861fe05b4f070e12c776bfc26211ed96dd379
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Security for calc-rs-lang 0.3.4

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for calc_rs_lang-0.3.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

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.

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