Skip to content

Cache Utility

Lightweight caching utilities for ReaxKit objects.

This module provides minimal helpers for serializing and deserializing Python objects to disk using pickle. It is intended for caching intermediate results such as parsed handlers, analysis outputs, or precomputed tables to avoid repeated expensive computations.

The API is intentionally small and explicit to keep caching behavior predictable and easy to reason about.

CacheConfig dataclass

Configuration options for cache serialization.

Parameters:

Name Type Description Default
protocol int

Pickle protocol version to use when saving objects.

HIGHEST_PROTOCOL
compress bool

Placeholder flag for future compression support.

False

load_cache_blob(path, *, cfg=None)

Load a Python object from a cache file.

Parameters:

Name Type Description Default
path Path

Path to the cache file.

required
cfg CacheConfig

Cache configuration (reserved for future extensions).

None

Returns:

Type Description
Any

Deserialized Python object stored in the cache.

save_cache_blob(path, obj, *, cfg=None)

Save a Python object to a cache file.

The object is serialized using pickle and written to the specified path. Existing files will be overwritten.

Parameters:

Name Type Description Default
path Path

Destination path for the cache file.

required
obj Any

Python object to serialize.

required
cfg CacheConfig

Cache configuration controlling serialization behavior.

None

Returns:

Type Description
None