Skip to content

Commit

Permalink
CLI Speed improvements. (#23189)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzarc authored Mar 1, 2024
1 parent 8b8f730 commit 1875659
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/python/qmk/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from functools import lru_cache
from typing import OrderedDict
from pathlib import Path
from copy import deepcopy

from milc import cli

Expand All @@ -22,7 +23,8 @@ def _dict_raise_on_duplicates(ordered_pairs):
return d


def json_load(json_file, strict=True):
@lru_cache(maxsize=20)
def _json_load_impl(json_file, strict=True):
"""Load a json file from disk.
Note: file must be a Path object.
Expand All @@ -42,7 +44,11 @@ def json_load(json_file, strict=True):
exit(1)


@lru_cache(maxsize=0)
def json_load(json_file, strict=True):
return deepcopy(_json_load_impl(json_file=json_file, strict=strict))


@lru_cache(maxsize=20)
def load_jsonschema(schema_name):
"""Read a jsonschema file from disk.
"""
Expand All @@ -57,7 +63,7 @@ def load_jsonschema(schema_name):
return json_load(schema_path)


@lru_cache(maxsize=0)
@lru_cache(maxsize=1)
def compile_schema_store():
"""Compile all our schemas into a schema store.
"""
Expand All @@ -73,7 +79,7 @@ def compile_schema_store():
return schema_store


@lru_cache(maxsize=0)
@lru_cache(maxsize=20)
def create_validator(schema):
"""Creates a validator for the given schema id.
"""
Expand Down

0 comments on commit 1875659

Please sign in to comment.