]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
tomllib: Add a comment about implicit lru_cache bound (GH-126078)
authorTaneli Hukkinen <3275109+hukkin@users.noreply.github.com>
Tue, 29 Oct 2024 10:36:14 +0000 (12:36 +0200)
committerGitHub <noreply@github.com>
Tue, 29 Oct 2024 10:36:14 +0000 (11:36 +0100)
Lib/tomllib/_re.py

index 994bb7493fd92865e6ab87c277ba5741b44c31a9..9eacefc729544e3c8e223eb189be1c16da877da6 100644 (file)
@@ -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