Skip to content

Commit

Permalink
Speedup by ~50x team and user import
Browse files Browse the repository at this point in the history
  • Loading branch information
edomora97 authored and wil93 committed Oct 5, 2024
1 parent 61c94e7 commit 1a687a4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmscontrib/loaders/italy_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import os.path
import sys
from datetime import timedelta
from copy import deepcopy

import yaml

Expand Down Expand Up @@ -61,9 +62,15 @@ def getmtime(fname):
return os.stat(fname).st_mtime


yaml_cache = {}

def load_yaml_from_path(path):
if path in yaml_cache:
return yaml_cache[path]
with open(path, "rt", encoding="utf-8") as f:
return yaml.safe_load(f)
value = yaml.safe_load(f)
yaml_cache[path] = value
return deepcopy(value)


def load(src, dst, src_name, dst_name=None, conv=lambda i: i):
Expand Down

0 comments on commit 1a687a4

Please sign in to comment.