Skip to content

Rkf Handler Engine Utility

Load AMS .kf/.rkf files with process-local handle caching.

This module centralizes lazy KFFile construction and cache-key generation for AMS-backed engine loaders. It is intentionally small and only manages handle lifecycle concerns (existence checks, optional load timing callback, and in-memory reuse keyed by file identity).

Usage context

  • Adapter internals: Reused by AMSAdapter loaders to avoid repeated opens.
  • Runtime performance: Skips expensive re-loads for unchanged KF/RKF files.
  • Diagnostics: Emits optional per-load timing via callback when uncached.

Class: RKFHandler

Cached loader for AMS KFFile handles.

Method: clear_runtime_cache

Clear all cached KFFile handles for the current Python process.

Returns:

Type Description
None

Examples:

RKFHandler.clear_runtime_cache()

Method: kf

Return a cached AMS KFFile handle for this path.

Loads on first access and then reuses the same in-memory handle for subsequent calls while the underlying file identity is unchanged.

Returns:

Type Description
Any

scm.plams.tools.kftools.KFFile instance bound to self.path.

Examples:

handler = RKFHandler("reaxout.kf")
kf = handler.kf()