Skip to content

sift_py.yaml.utils

FUNCTION DESCRIPTION
try_fast_yaml_load

Try to load the YAML file using the fastest available parser.

try_fast_yaml_load

try_fast_yaml_load(path: Path) -> Dict[Any, Any]

Try to load the YAML file using the fastest available parser.

Order of preference:

  1. rapidyaml (ryml) - C++ binding, ~100x faster than pyyaml on large files. Requires pip install rapidyaml. See :func:_rapidyaml_load for caveats (notably: no YAML 1.1 merge-key semantics).
  2. pyyaml.CSafeLoader - libyaml-backed, bundled with most pyyaml wheels but not every Python/platform combination.
  3. pyyaml.safe_load - pure-Python fallback.

rapidyaml failures are not swallowed silently: if ryml is installed but raises while parsing path, the exception propagates so the regression is visible rather than masked by the pyyaml fallback.