---
title: SizeClass
description: One of the five documented size classes.
---

```python
@final
class SizeClass
```

One of the five documented size classes.

`minimumMemoryInMiB` selects a class; it does not size a VM. Both numbers are on the
class or neither, because naming only the peak invites budgeting for memory nobody is
billed for and naming only the baseline invites a pressure test against a ceiling four
times too low.

## Constructor

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

## Properties

### `baseline_gb`

```python
baseline_gb: float
```

The figure a GB-second rate multiplies. Always the baseline, never the peak.

### `baseline_mib`

```python
baseline_mib: int
```

### `baseline_vcpu`

```python
baseline_vcpu: float
```

### `peak_gb`

```python
peak_gb: float
```

The peak in GB, which is what the guest reports as `MemTotal`.

### `peak_mib`

```python
peak_mib: int
```

### `peak_vcpu`

```python
peak_vcpu: float
```

## Methods

### `all`

```python
@staticmethod
def all() -> list[SizeClass]
```

Every class, smallest first.

### `default_class`

```python
@staticmethod
def default_class() -> SizeClass
```

The platform's default, 2048 MiB. Not the smallest — a 0.5 GB baseline fixes the
guest's always-present ceiling at 2 GB, which OOM-kills a real test suite, and the
guest has no swap.

### `describe`

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

One line naming both numbers. `cli.py` calls this `describe()`.

### `from_baseline_mib`

```python
@staticmethod
def from_baseline_mib(mib: SupportsIndex) -> SizeClass
```

The class `minimumMemoryInMiB = mib` selects, or a refusal (TRAP-10).

Off-table figures are refused rather than snapped to a neighbour: the two
plausible readings differ in both memory and rate, and neither has been measured.

### `from_request`

```python
@staticmethod
def from_request(
    cpus: SupportsFloat | SupportsIndex | None = None,
    memory_mib: SupportsIndex | None = None,
) -> SizeClass
```

The smallest class whose baseline covers a resource request (BIND-14).

`cpus` in vCPUs and `memory_mib` in MiB, each a request; `None` or zero is no
requirement on that axis, and with none on either the answer is `default_class()`.
Chosen by baseline, the billed and always-present figure. Raises `InvalidArgError`
naming the largest class when no class covers the request, or for a CPU figure that is
not a finite non-negative number.

## 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.