---
title: Duration
description: Seconds, plus how we know them.
---

```python
@final
class Duration
```

Seconds, plus how we know them.

There is **no** `__new__`: naming a provenance is the only way to build one, and the
two named constructors are the only doors. `cost.py` achieved the same thing with a
field that had no default, so `Duration(3600)` raised `TypeError` — here there is
nothing to call, which is one rung stronger.

## Constructor

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

## Properties

### `is_measured`

```python
is_measured: bool
```

True only for a timed span. What `CostReport.fully_measured` reads.

### `provenance`

```python
provenance: str
```

`"measured"` or `"projected"`, spelled as the Python `StrEnum` member.

### `seconds`

```python
seconds: float
```

The span in seconds, without its label.

A float here and not on the money types, deliberately: seconds really are a
measurement a caller does arithmetic on, and the core's own
`break_even_seconds_f64` makes the same distinction for the same reason.

## Methods

### `measured`

```python
@staticmethod
def measured(seconds: SupportsFloat | SupportsIndex) -> Duration
```

A timed phase: a clock ran and this is what it read.

Fallible because the float is — a negative or non-finite figure has no reading as
a duration, and the refusal is the core's `duration_of_secs_f64`.

### `projected`

```python
@staticmethod
def projected(seconds: SupportsFloat | SupportsIndex) -> Duration
```

A hypothetical phase: an estimate's input, or a documented minimum nobody timed.

## Special methods

### `__repr__`

```python
def __repr__() -> str
```

### `__str__`

```python
def __str__() -> str
```

## Provenance

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.