perf: read yaml through the c loader

Loading the emulator profiles is the most expensive step of every
command here, and all forty call sites used the pure-Python scanner
while libyaml sat unused in the same wheel. One shared yaml_load picks
the C loader when pyyaml ships it: the 375 profiles parse in 0.18s
instead of 1.39s, and verify --platform retroarch drops from 2.17s to
0.73s. The loader class is the same restricted one safe_load uses.

es_bios.xml was parsed straight from the network while install.py
already refused a document declaring entities; both now share one
guard. Scrapers reach it through a single path bootstrap in the
package rather than two ad-hoc ones.
This commit is contained in:
Abdessamad Derraz committed 2026-08-11 00:55:16 +02:00
1 parent ab6a3bb26d
commit 3b8f2d75d5
18 files changed
+109 -42

No files matched your search

+2 -1
View File
@@ -20,6 +20,7 @@ from common import (
load_platform_config,
load_target_config,
require_yaml,
yaml_load,
)
from truth import generate_platform_truth
@@ -72,7 +73,7 @@ def main(argv: list[str] | None = None) -> None:
# Load registry
registry_path = os.path.join(args.platforms_dir, "_registry.yml")
with open(registry_path) as f:
registry = (yaml.safe_load(f) or {}).get("platforms", {})
registry = (yaml_load(f) or {}).get("platforms", {})
# Load emulator profiles
profiles = load_emulator_profiles(args.emulators_dir)