# Serialization

> USearch for Python

```python
index.on(pool).save("index.safegraphs")
copy = DenseIndex.load_ram("index.safegraphs", executor=pool)  # A new, mutable index in host memory
view = DenseIndex.view_ram("index.safegraphs")  # Served in place, read-only
```

Loading creates a handle rather than filling one, its geometry read from the checkpoint's own headers, and a cancelled or failed load creates none.
The executor a load fans out over is its `executor=` keyword, and without one it reads on the calling thread.
A view maps the file instead of copying it, so opening costs the headers alone, and every mutating verb on it raises `ReadOnlyError`.
To learn a checkpoint's shape without opening a shard, ask for its metadata, a `DenseMetadata` struct sequence whose fields are the geometry every empty constructor takes:

```python
metadata = DenseIndex.metadata_read("index.safegraphs")
empty = DenseIndex.init_ram(
    metadata.dimensions, metadata.metric, metadata.quantization, connectivity=metadata.connectivity
)
```

Residency is never among those fields, because where the payload lives stays the caller's choice.

`save_buffer` returns one monolith of every shard as a `Monolith` over the arena it is handed, and `load_ram_buffer` and `metadata_read_buffer` read one back from any buffer.

`from usearch import Monolith, DenseMetadata`

## Monolith

The bytes [`save_buffer`](https://www.unum.cloud/docs/usearch/python/metrics.md#save_buffer) wrote into an [`Arena`](https://www.unum.cloud/docs/usearch/python/inputs-and-outputs.md#Arena), one (length,) run of 'B'.

```python
class Monolith
```

## __buffer__

Host memory only; device memory raises [`DeviceError`](https://www.unum.cloud/docs/usearch/python/errors.md#DeviceError), a rewound arena [`UninitializedError`](https://www.unum.cloud/docs/usearch/python/errors.md#UninitializedError).

```python
def __buffer__(flags: int, /) -> memoryview
```

Python-only.

## __len__

Rows, or bytes of a [`Monolith`](#Monolith).

```python
def __len__() -> int
```

Python-only.

## __cuda_array_interface__

Version 3 of the CUDA Array Interface, present only over device memory.

```python
__cuda_array_interface__: dict[str, Any]
```

Python-only.

## DenseMetadata

The geometry and metric a checkpoint froze.

```python
class DenseMetadata(structseq[Any], tuple[int, DenseMetric, Scalar, int])
```

## dimensions

Scalars per stored vector.

```python
dimensions: int
```

## metric

The [`DenseMetric`](https://www.unum.cloud/docs/usearch/python/metrics.md#DenseMetric) the checkpoint scores with.

```python
metric: DenseMetric
```

## quantization

The [`Scalar`](https://www.unum.cloud/docs/usearch/python/inputs-and-outputs.md#Scalar) its vectors are stored and quantized into.

```python
quantization: Scalar
```

## connectivity

Connections per node the graph was built with.

```python
connectivity: int
```

