diff options
| author | Nick Brassel <nick@tzarc.org> | 2024-03-02 08:45:01 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-02 08:45:01 +1100 |
| commit | 1875659df025ec83201bb8e1e4515100e5152a87 (patch) | |
| tree | 3cd45d7170b16f458dd529d0dea01622673c31d3 /lib/python | |
| parent | 8b8f73098b325ea60e2affea6dcd36fc86716dab (diff) | |
CLI Speed improvements. (#23189)
Diffstat (limited to 'lib/python')
| -rw-r--r-- | lib/python/qmk/json_schema.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/python/qmk/json_schema.py b/lib/python/qmk/json_schema.py index b00df749cc..1d5f863807 100644 --- a/lib/python/qmk/json_schema.py +++ b/lib/python/qmk/json_schema.py | |||
| @@ -7,6 +7,7 @@ from collections.abc import Mapping | |||
| 7 | from functools import lru_cache | 7 | from functools import lru_cache |
| 8 | from typing import OrderedDict | 8 | from typing import OrderedDict |
| 9 | from pathlib import Path | 9 | from pathlib import Path |
| 10 | from copy import deepcopy | ||
| 10 | 11 | ||
| 11 | from milc import cli | 12 | from milc import cli |
| 12 | 13 | ||
| @@ -22,7 +23,8 @@ def _dict_raise_on_duplicates(ordered_pairs): | |||
| 22 | return d | 23 | return d |
| 23 | 24 | ||
| 24 | 25 | ||
| 25 | def json_load(json_file, strict=True): | 26 | @lru_cache(maxsize=20) |
| 27 | def _json_load_impl(json_file, strict=True): | ||
| 26 | """Load a json file from disk. | 28 | """Load a json file from disk. |
| 27 | 29 | ||
| 28 | Note: file must be a Path object. | 30 | Note: file must be a Path object. |
| @@ -42,7 +44,11 @@ def json_load(json_file, strict=True): | |||
| 42 | exit(1) | 44 | exit(1) |
| 43 | 45 | ||
| 44 | 46 | ||
| 45 | @lru_cache(maxsize=0) | 47 | def json_load(json_file, strict=True): |
| 48 | return deepcopy(_json_load_impl(json_file=json_file, strict=strict)) | ||
| 49 | |||
| 50 | |||
| 51 | @lru_cache(maxsize=20) | ||
| 46 | def load_jsonschema(schema_name): | 52 | def load_jsonschema(schema_name): |
| 47 | """Read a jsonschema file from disk. | 53 | """Read a jsonschema file from disk. |
| 48 | """ | 54 | """ |
| @@ -57,7 +63,7 @@ def load_jsonschema(schema_name): | |||
| 57 | return json_load(schema_path) | 63 | return json_load(schema_path) |
| 58 | 64 | ||
| 59 | 65 | ||
| 60 | @lru_cache(maxsize=0) | 66 | @lru_cache(maxsize=1) |
| 61 | def compile_schema_store(): | 67 | def compile_schema_store(): |
| 62 | """Compile all our schemas into a schema store. | 68 | """Compile all our schemas into a schema store. |
| 63 | """ | 69 | """ |
| @@ -73,7 +79,7 @@ def compile_schema_store(): | |||
| 73 | return schema_store | 79 | return schema_store |
| 74 | 80 | ||
| 75 | 81 | ||
| 76 | @lru_cache(maxsize=0) | 82 | @lru_cache(maxsize=20) |
| 77 | def create_validator(schema): | 83 | def create_validator(schema): |
| 78 | """Creates a validator for the given schema id. | 84 | """Creates a validator for the given schema id. |
| 79 | """ | 85 | """ |
