Skip to content

Commit 00bede6

Browse files
serge-sans-paillebadboy
authored andcommitted
Bug 1886479 - Eventually use CSafeLoader as yaml loader
It is significantly faster than the Python parser. It saves more than 25% of the execution time when running the `run_glean_parser.py gifft_map` script in the Firefox codebase.
1 parent 11489af commit 00bede6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

glean_parser/util.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
from jsonschema import _utils # type: ignore
2121
import yaml
2222

23+
try:
24+
from yaml import CSafeLoader as SafeLoader
25+
except ImportError:
26+
from yaml import SafeLoader # type: ignore
27+
2328

2429
def date_fromisoformat(datestr: str) -> datetime.date:
2530
return datetime.date.fromisoformat(datestr)
@@ -44,7 +49,7 @@ class DictWrapper(dict):
4449
pass
4550

4651

47-
class _NoDatesSafeLoader(yaml.SafeLoader):
52+
class _NoDatesSafeLoader(SafeLoader):
4853
@classmethod
4954
def remove_implicit_resolver(cls, tag_to_remove):
5055
"""

0 commit comments

Comments
 (0)