Skip to content

Commit

Permalink
replace cache size magic number of 128 with a module level constant (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronayres35 authored Nov 11, 2020
1 parent 2efd997 commit c9650a7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion traits/observation/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

_LARK_PARSER = _generated_parser.Lark_StandAlone()

#: Maximum number of parsed observer expressions stored in the LRU cache
_OBSERVER_EXPRESSION_CACHE_MAXSIZE = 128


def _handle_series(trees, default_notifies):
""" Handle expressions joined in series using "." or ":" connectors.
Expand Down Expand Up @@ -254,7 +257,7 @@ def _handle_tree(tree, default_notifies=None):
tree.children, default_notifies=default_notifies)


@lru_cache(maxsize=128)
@lru_cache(maxsize=_OBSERVER_EXPRESSION_CACHE_MAXSIZE)
def parse(text):
""" Top-level function for parsing user's text to an ObserverExpression.
Expand Down

0 comments on commit c9650a7

Please sign in to comment.