Skip to content

EstimatedUsd

@final
class EstimatedUsd

Dollars derived from published rates. Not the bill.

There is no way to get a number out of this

No __float__, no __int__, no __index__, no __add__. [Self::amount] answers a string — the decimal figure at full precision — so float(usd) raises TypeError, usd + usd raises TypeError, and the cheapest laundering spelling (f"${float(x):.2f}") does not run. The core makes this a compile error; the closest Python equivalent is an absence, and this is it.

A caller who genuinely needs arithmetic writes Decimal(usd.amount), which is one visible step, keeps the type name at the call site, and is a decision a reviewer sees.

EstimatedUsd declares no __new__ or __init__, so it is not constructed directly: an instance comes back from another call in this package.

amount: str

The figure as an exact decimal string.

A string and not a float, which is the whole of COST-2 at this boundary. The core carries a rust_decimal::Decimal and the exact spelling of it is what survives into Decimal(...) on the Python side; an f64 would already have lost the exactness the type exists to hold.

display_amount: str

The figure at display precision: two places at a dollar or more, six below.

A create-and-destroy suite’s compute cost lives in the sixth decimal place while a warm pool’s monthly bill lives in the second, and one fixed precision cannot show both.

def __repr__() -> str
def __str__() -> str

~$X (estimated) — the label travels with the figure, because a number copied out of a terminal loses its docstring.

This page is generated from bindings/microvms-py/microvms.pyi by Griffe 2.3.0, run from site/scripts/gen-reference.mjs on every pnpm run sync, so an edit made here is overwritten by the next run.

To change the page, change the doc comment in the binding’s Rust source, then regenerate the declarations with mise run stubs. mise run stubs:check fails when the committed file no longer matches the source.