Skip to content

Commit

Permalink
Bug 1886479 - Eventually use CSafeLoader as yaml loader
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
serge-sans-paille authored and badboy committed Mar 21, 2024
1 parent 11489af commit 00bede6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion glean_parser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
from jsonschema import _utils # type: ignore
import yaml

try:
from yaml import CSafeLoader as SafeLoader
except ImportError:
from yaml import SafeLoader # type: ignore


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


class _NoDatesSafeLoader(yaml.SafeLoader):
class _NoDatesSafeLoader(SafeLoader):
@classmethod
def remove_implicit_resolver(cls, tag_to_remove):
"""
Expand Down

0 comments on commit 00bede6

Please # to comment.