We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a9b1ca7 commit 4e5d855Copy full SHA for 4e5d855
1 file changed
src/hyperbase/parsers/utils.py
@@ -1,8 +1,17 @@
1
+from functools import lru_cache
2
+
3
from hyperbase.hyperedge import Hyperedge
4
5
6
+@lru_cache(maxsize=2048)
7
def clean_alphanumeric(s: str) -> str:
- """Lowercase ``s`` and strip every non-alphanumeric character."""
8
+ """Lowercase ``s`` and strip every non-alphanumeric character.
9
10
+ Memoized: this is a pure ``str -> str`` map called many times on the same
11
+ small set of token / atom-label strings (e.g. the correctness check runs it
12
+ per token per candidate during the parser's correctness search). The cache
13
+ is bounded so long-running workers / REPLs don't grow it without limit.
14
+ """
15
return "".join(c.lower() for c in s if c.isalnum())
16
17
0 commit comments