From 5ddf4a61d211c9db2e49a081fa26562d57313db3 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 23 Apr 2023 08:35:43 -0400 Subject: Cache `class_is_abstract()` For one project in the pylint primer (music21), provides 15% speedup linting the entire project. --- pylint/checkers/utils.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pylint') diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 38321bc11..c76c767aa 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1130,6 +1130,7 @@ def node_ignores_exception( return any(get_contextlib_suppressors(node, exception)) +@lru_cache(maxsize=1024) def class_is_abstract(node: nodes.ClassDef) -> bool: """Return true if the given class node should be considered as an abstract class. @@ -2191,6 +2192,7 @@ def overridden_method( def clear_lru_caches() -> None: """Clear caches holding references to AST nodes.""" caches_holding_node_references: list[_lru_cache_wrapper[Any]] = [ + class_is_abstract, in_for_else_branch, infer_all, is_overload_stub, -- cgit v1.2.1