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

+4 -2
View File
@@ -18,6 +18,8 @@ from pathlib import Path
import yaml
from common import yaml_load
from .base_scraper import BaseScraper, BiosRequirement
PLATFORM_NAME = "batocera"
@@ -203,7 +205,7 @@ class Scraper(BaseScraper):
raise ConnectionError(
f"Failed to fetch {CONFIGGEN_DEFAULTS_URL}: {e}"
) from e
data = yaml.safe_load(raw)
data = yaml_load(raw)
cores: set[str] = set()
standalone: set[str] = set()
for system, cfg in data.items():
@@ -386,7 +388,7 @@ class Scraper(BaseScraper):
)
if existing.exists():
with open(existing) as f:
old = yaml.safe_load(f) or {}
old = yaml_load(f) or {}
batocera_version = str(old.get("version", ""))
cores, standalone = self._fetch_cores()