Code Refactor for Speed and Readability (#13074)

Refactor code for speed and clarity

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Paula DerrengerandGlenn Jocher authored and GitHub committed 2024-06-09 04:21:38 +02:00
1 parent 3ec95f9e3d
commit 3742ab493d
2 files changed
+8 -5

No files matched your search

+3 -1
View File
@@ -616,10 +616,12 @@ def yaml_load(file="data.yaml"):
return yaml.safe_load(f)
def yaml_save(file="data.yaml", data={}):
def yaml_save(file="data.yaml", data=None):
"""Safely saves `data` to a YAML file specified by `file`, converting `Path` objects to strings; `data` is a
dictionary.
"""
if data is None:
data = {}
with open(file, "w") as f:
yaml.safe_dump({k: str(v) if isinstance(v, Path) else v for k, v in data.items()}, f, sort_keys=False)