diff options
Diffstat (limited to 'pylint/message/message_definition_store.py')
-rw-r--r-- | pylint/message/message_definition_store.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pylint/message/message_definition_store.py b/pylint/message/message_definition_store.py index c160a85ba..766cdd446 100644 --- a/pylint/message/message_definition_store.py +++ b/pylint/message/message_definition_store.py @@ -2,6 +2,7 @@ # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE import collections +import functools from typing import TYPE_CHECKING, Dict, List, Tuple, ValuesView from pylint.exceptions import UnknownMessageError @@ -46,8 +47,14 @@ class MessageDefinitionStore: self._messages_definitions[message.msgid] = message self._msgs_by_category[message.msgid[0]].append(message.msgid) + @functools.lru_cache() def get_message_definitions(self, msgid_or_symbol: str) -> List[MessageDefinition]: - """Returns the Message definition for either a numeric or symbolic id.""" + """Returns the Message definition for either a numeric or symbolic id. + + The cache has no limit as its size will likely stay minimal. For each message we store + about 1000 characters, so even if we would have 1000 messages the cache would only + take up ~= 1 Mb. + """ return [ self._messages_definitions[m] for m in self.message_id_store.get_active_msgids(msgid_or_symbol) |