Skip to content

Commit 1a687a4

Browse files
edomora97wil93
authored andcommitted
Speedup by ~50x team and user import
1 parent 61c94e7 commit 1a687a4

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

cmscontrib/loaders/italy_yaml.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import os.path
2929
import sys
3030
from datetime import timedelta
31+
from copy import deepcopy
3132

3233
import yaml
3334

@@ -61,9 +62,15 @@ def getmtime(fname):
6162
return os.stat(fname).st_mtime
6263

6364

65+
yaml_cache = {}
66+
6467
def load_yaml_from_path(path):
68+
if path in yaml_cache:
69+
return yaml_cache[path]
6570
with open(path, "rt", encoding="utf-8") as f:
66-
return yaml.safe_load(f)
71+
value = yaml.safe_load(f)
72+
yaml_cache[path] = value
73+
return deepcopy(value)
6774

6875

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

0 commit comments

Comments
 (0)