summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaneli Hukkinen <3275109+hukkin@users.noreply.github.com>2024-10-29 10:36:14 (GMT)
committerGitHub <noreply@github.com>2024-10-29 10:36:14 (GMT)
commit67f5c5bd6fcc956a785edef3be67e8cbe470cd31 (patch)
tree09ff2b521b14c04cce230393935308c65d52f29c
parenta64a1c920660b0c1e4dd5a9573004cd527e15184 (diff)
downloadcpython-67f5c5bd6fcc956a785edef3be67e8cbe470cd31.zip
cpython-67f5c5bd6fcc956a785edef3be67e8cbe470cd31.tar.gz
cpython-67f5c5bd6fcc956a785edef3be67e8cbe470cd31.tar.bz2
tomllib: Add a comment about implicit lru_cache bound (GH-126078)
-rw-r--r--Lib/tomllib/_re.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/tomllib/_re.py b/Lib/tomllib/_re.py
index 994bb74..9eacefc 100644
--- a/Lib/tomllib/_re.py
+++ b/Lib/tomllib/_re.py
@@ -84,6 +84,9 @@ def match_to_datetime(match: re.Match) -> datetime | date:
return datetime(year, month, day, hour, minute, sec, micros, tzinfo=tz)
+# No need to limit cache size. This is only ever called on input
+# that matched RE_DATETIME, so there is an implicit bound of
+# 24 (hours) * 60 (minutes) * 2 (offset direction) = 2880.
@lru_cache(maxsize=None)
def cached_tz(hour_str: str, minute_str: str, sign_str: str) -> timezone:
sign = 1 if sign_str == "+" else -1