From 6b0cac5843d0cbfb68391f36397e6759e13e297d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 3 May 2024 16:42:26 -0400 Subject: [PATCH] perf: cache _human_key to speed html report by about 10% --- coverage/misc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coverage/misc.py b/coverage/misc.py index d5d96fb13..af28d7d56 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -8,6 +8,7 @@ import contextlib import datetime import errno +import functools import hashlib import importlib import importlib.util @@ -313,6 +314,7 @@ def import_local_file(modname: str, modfile: str | None = None) -> ModuleType: return mod +@functools.lru_cache(maxsize=None) def _human_key(s: str) -> tuple[list[str | int], str]: """Turn a string into a list of string and number chunks.